> 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 : http://msdn.microsoft.com/en-us/library/aa175912.aspx that :
Unfortunately, the name of the column default constraint isn't kept in the ANSI COLUMNS view, so you must go back to the system tables to find the name
The only way I found to get the name of the DEFAULT constraint is this request :
select t_obj.name as TABLE_NAME ,c_obj.name as CONSTRAINT_NAME ,col.name as COLUMN_NAMEfrom sysobjects c_objjoin sysobjects t_obj on c_obj.parent_obj = t_obj.id join sysconstraints con on c_obj.id = con.constidjoin syscolumns col on t_obj.id = col.id and con.colid = col.colidwhere c_obj.xtype = 'D'
Am I the only one to find it crazy to be unable to delete easily a constraint that only concerns the columns I'm trying to drop ?
I need to execute a request with 3 joins just to get the name...