Answers for "how to drop all constraints on a column in sql server"

SQL
1

drop table with constraints

1. 'First Drop contrstraints like this'
ALTER TABLE table_name
DROP CONSTRAINT constraint_name;
2. 'Then drop table'
DROP TABLE table_name;
Posted by: Guest on February-19-2021
0

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
Posted by: Guest on October-08-2021

Code answers related to "how to drop all constraints on a column in sql server"

Code answers related to "SQL"

Browse Popular Code Answers by Language