Wednesday, September 5, 2012

T-SQL Drop and Re-create Unique Constraint

ALTER TABLE [dbo].[TABLE_NAME]
DROP CONSTRAINT [UNIQUE_KEY_NAME]
GO

ALTER TABLE [dbo].[TABLE_NAME]
ADD CONSTRAINT [UNIQUE_KEY_NAME] UNIQUE NONCLUSTERED
(
    [COLUMN_ID_1] ASC,
    [COLUMN_ID_2] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO

No comments: