-
-
Save LSTANCZYK/0ef1331f68ce505be314 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment