Quantcast
Channel: SQL Server 2005 drop column with constraints - Stack Overflow
Browsing latest articles
Browse All 14 View Live
↧

Answer by Stealth Rabbi for SQL Server 2005 drop column with constraints

Just to build on Jeremy Stein's answer, I created a stored procedure for this, and set it up so it can be used to delete a column that has or does not have default constraints. It's not real efficient...

View Article


Answer by Steve for SQL Server 2005 drop column with constraints

The answer from pvolders was just what I needed but it missed statistics which were causing and error. This is the same code, minus creating a stored procedure, plus enumerating statistics and dropping...

View Article

Answer by Jeroen for SQL Server 2005 drop column with constraints

Looking up the name of the contraint or using MSSQL design view is not always an option. I currently want to make a script for deleting a column with a contraint on it. Using the name is not an option...

View Article

Answer by Bitmask for SQL Server 2005 drop column with constraints

I just ran into this. You can delete the column with constraints using MSSQL design view. Right click on the column you want to be dropped (with or without constraints) and you are able to delete this...

View Article

Answer by pvolders for SQL Server 2005 drop column with constraints

I also think it's a shortcoming in SQL server to not have a cascading drop available. I worked my way around it by querying the system tables in the same way as other people described...

View Article


Answer by jjroman for SQL Server 2005 drop column with constraints

Perhaps it could help a little more:declare @tablename nvarchar(200)declare @colname nvarchar(200)declare @default sysname, @sql nvarchar(max)set @tablename = 'your table'set @colname = 'column to...

View Article

Answer by Jeremy Stein for SQL Server 2005 drop column with constraints

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 SQL Server 2005 drop column with constraints

This query finds default constraints for a given table. It aint 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 SQL Server 2005 drop column with constraints

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

View Article


Answer by Julien N for SQL Server 2005 drop column with constraints

> 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 SQL Server 2005 drop column with constraints

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 SQL Server 2005 drop column with constraints

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 SQL Server 2005 drop column with constraints

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


SQL Server 2005 drop column with constraints

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 latest articles
Browse All 14 View Live




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