adding unique constraint in sql
snippet in sql

set column as unique in sql server

user8693

ALTER TABLE Persons
ADD UNIQUE (ID);

sql unique

user5392

-- To name a UNIQUE constraint, and to define a UNIQUE constraint on 
-- multiple columns, use the following SQL syntax:

-- MySQL / SQL Server / Oracle / MS Access:

CREATE TABLE Persons (
    ID int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int,
    CONSTRAINT UC_Person UNIQUE (ID,LastName)
); 

adding unique constraint in sql

user2816


ALTER TABLE Persons

ADD UNIQUE (ID); 

unique constraint mssql

user9709

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