Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

drop constraint in ms sql

DECLARE @sql NVARCHAR(MAX)
WHILE 1=1
BEGIN
    SELECT TOP 1 @sql = N'alter table tbloffers drop constraint ['+dc.NAME+N']'
    from sys.default_constraints dc
    JOIN sys.columns c
        ON c.default_object_id = dc.object_id
    WHERE 
        dc.parent_object_id = OBJECT_ID('tbloffers')
    AND c.name = N'checkin'
    IF @@ROWCOUNT = 0 BREAK
    EXEC (@sql)
END
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #drop #constraint #ms #sql
ADD COMMENT
Topic
Name
9+7 =