Delete Unique Constraints
Applies to:
SQL Server 2016 (13.x) and later
Azure SQL Database
Azure SQL Managed Instance
You can delete a unique constraint in SQL Server by using SQL Server Management Studio or Transact-SQL. Deleting a unique constraint removes the requirement for uniqueness for values entered in the column or combination of columns included in the constraint expression and deletes the corresponding unique index.
In This Topic
Before you begin:
To delete a unique constraint, using:
Before You Begin
Security
Permissions
Requires ALTER permission on the table.
Using SQL Server Management Studio
To delete a unique constraint using Object Explorer
In Object Explorer, expand the table that contains the unique constraint and then expand Constraints.
Right-click the key and select Delete.
In the Delete Object dialog box, verify the correct key is specified and click OK.
To delete a unique constraint using Table Designer
In Object Explorer, right-click the table with the unique constraint, and click Design.
On the Table Designer menu, click Indexes/Keys.
In the Indexes/Keys dialog box, select the unique key in the Selected Primary/Unique Key and Index list.
Click Delete.
On the File menu, click Save table name.
Using Transact-SQL
To delete a unique constraint
In Object Explorer, connect to an instance of Database Engine.
On the Standard bar, click New Query.
Copy and paste the following example into the query window and click Execute.
-- Return the name of unique constraint. SELECT name FROM sys.objects WHERE type = 'UQ' AND OBJECT_NAME(parent_object_id) = N' DocExc'; GO -- Delete the unique constraint. ALTER TABLE dbo.DocExc DROP CONSTRAINT UNQ_ColumnB_DocExc; GO
For more information, see ALTER TABLE (Transact-SQL) and sys.objects (Transact-SQL).