Create Proc [dbo].[Proc_DropConstraints]
@TableName sysname,
@ColumnName sysname
as
Declare @SQL nvarchar(1000)
Declare RS Cursor local read_only for
Select 'Alter Table ' + @TableName+
' drop constraint '+ quotename(object_name(constid))
from sysconstraints where id=object_id(@TableName) and
colid=(Select colid from syscolumns where id=sysconstraints.id and
name like @ColumnName)
Open RS
fetch next from RS into @SQL
while @@FETCH_STATUS=0
begin
exec sp_executesql @SQL
fetch next from RS into @SQL
end
GO