Quantcast
Channel: How to drop a column with constraints in SQL Server 2005 - Stack Overflow
Browsing all 28 articles
Browse latest View live

Answer by Jeremy Stein for How to drop a column with constraints in SQL...

Here is a script that will delete the column along with its default constraint. Replace MYTABLENAME and MYCOLUMNNAME appropriately.declare @constraint_name sysname, @sql nvarchar(max)select...

View Article


Answer by edosoft for How to drop a column with constraints in SQL Server 2005

This query finds default constraints for a given table. It ain't pretty, I agree:select col.name, col.column_id, col.default_object_id, OBJECTPROPERTY(col.default_object_id, N'IsDefaultCnst') as...

View Article


Answer by Rob for How to drop a column with constraints in SQL Server 2005

Just Generate Scripts for the table. There you can find the name of all constraints.

View Article

Answer by Julien N for How to drop a column with constraints in SQL Server 2005

> select CONSTRAINT_NAME from INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE> WHERE TABLE_NAME = '<tablename>' AND COLUMN_NAME = 'IsClosed'It's not the right solution as it is explained here :...

View Article

Answer by DCNYAM for How to drop a column with constraints in SQL Server 2005

I believe explicitly dropping the constraints prior to dropping the column is a "cleaner" solution. This way, you don't drop constraints you may not be aware of. If the drop still fails, you know there...

View Article


Answer by Steve Sheldon for How to drop a column with constraints in SQL...

You can get the constraint names by querying the information_schema system views.select CONSTRAINT_NAME from INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE WHERE TABLE_NAME = '<tablename>' AND...

View Article

Answer by DCNYAM for How to drop a column with constraints in SQL Server 2005

What do you mean randomly generated? You can look up the constraints on the specific column in management studio or via the sys.tables view and find what the name(s) are.Then, you can change your...

View Article

How to drop a column with constraints in SQL Server 2005

I have a column with a "DEFAULT" constraint. I'd like to create a script that drops that column.The problem is that it returns this error:Msg 5074, Level 16, State 1, Line 1 The object...

View Article

Browsing all 28 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>