adsense

Thursday, June 7, 2018

SQL Server drop Unique Key script

While you can uses SSMS to easilly drop a Uniqe key, there may be situaitons where that needs to be done via a script.

Following script can be used to drop a Unique Key on a given column


IF  EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE table_name ='Employee' AND  CONSTRAINT_TYPE='UNIQUE' )
    ALTER TABLE [dbo].[Employee] DROP CONSTRAINT [UC_Employee_emp_code]
GO

Cheers,
Samitha

No comments:

Post a Comment