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

Answer by Stealth Rabbi for How to drop a column with constraints in SQL...

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 How to drop a column with constraints in SQL Server 2005

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 How to drop a column with constraints in SQL Server 2005

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 How to drop a column with constraints in SQL Server 2005

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 How to drop a column with constraints in SQL Server 2005

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 How to drop a column with constraints in SQL Server 2005

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


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