Articles → SQL SERVER → Unique Index In SQL Server

Unique Index In SQL Server






Purpose Of Unique Index




  1. Only unique values are allowed
  2. NULL value could be inserted.

Syntax


CREATE UNIQUE INDEX index_name ON table_name (column_name)



Example




Picture showing the schema of the sample table

Click to Enlarge



CREATE UNIQUE INDEX idx_unique_SampleTable_Test ON SampleTable (Test)




insert into SampleTable 
values 
  (null) insert into SampleTable 
values 
  ('value1') insert into SampleTable 
values 
  ('value2') insert into SampleTable 
values 
  ('value1')



















Posted By  -  Karan Gupta
 
Posted On  -  Sunday, January 1, 2017

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250