drop unique constraint on column sql server code example

Example 1: how to remove foreign key constraint in sql

USE AdventureWorks2012;  
GO  
ALTER TABLE dbo.DocExe   
DROP CONSTRAINT FK_Column_B;   
GO

Example 2: set column as unique in sql server

ALTER TABLE Persons
ADD UNIQUE (ID);

Example 3: how to drop a unique constraint in sql

SHOW CREATE TABLE [tableName]
-- Find the constraintID after CONSTRAINT 'constraintID'
ALTER TABLE [tableName] DROP FOREIGN KEY constraintID

Example 4: unique constraint mssql

USE AdventureWorks2012;  
GO  
CREATE TABLE Production.TransactionHistoryArchive4  
 (  
   TransactionID int NOT NULL,   
   CONSTRAINT AK_TransactionID UNIQUE(TransactionID)   
);   
GO

Tags:

Sql Example