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

Security

Permissions

Requires ALTER permission on the table.

Using SQL Server Management Studio

To delete a unique constraint using Object Explorer

  1. In Object Explorer, expand the table that contains the unique constraint and then expand Constraints.

  2. Right-click the key and select Delete.

  3. In the Delete Object dialog box, verify the correct key is specified and click OK.

To delete a unique constraint using Table Designer

  1. In Object Explorer, right-click the table with the unique constraint, and click Design.

  2. On the Table Designer menu, click Indexes/Keys.

  3. In the Indexes/Keys dialog box, select the unique key in the Selected Primary/Unique Key and Index list.

  4. Click Delete.

  5. On the File menu, click Save table name.

Using Transact-SQL

To delete a unique constraint

  1. In Object Explorer, connect to an instance of Database Engine.

  2. On the Standard bar, click New Query.

  3. 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).