title | description | author | ms.author | ms.date | ms.service | ms.subservice | ms.topic | helpviewer_keywords | monikerRange | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Delete Unique Constraints |
Delete Unique Constraints |
WilliamDAssafMSFT |
wiassaf |
10/12/2016 |
sql |
table-view-index |
how-to |
|
=azuresqldb-current||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current||=fabric |
[!INCLUDE sqlserver2016-asdb-asdbmi-fabricsqldb]
You can delete a unique constraint in [!INCLUDEssnoversion] by using [!INCLUDEssManStudioFull] or [!INCLUDEtsql]. 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:
Requires ALTER permission on the table.
-
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.
-
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.
-
In Object Explorer, connect to an instance of [!INCLUDEssDE].
-
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).