What are Unique constraints in SQL Server?
Unique constraints uniquely identifies each records in a database
Syntax
CREATE TABLE Table_name(
column1 Datatype1 NOT NULL,
column2 Datatype2 NOT NULL,
column3 Datatype3 NOT NULL,
column4 Datatype4 ,
UNIQUE(columnname));
Example
CREATE TABLE Table_name(
EmpID Int NOT NULL,
Emp_Name Varchar(200) NOT NULL,
Address Varchar(200) NOT NULL,
Age int,
UNIQUE(EmpId));
Unique constraints uniquely identifies each records in a database
Syntax
CREATE TABLE Table_name(
column1 Datatype1 NOT NULL,
column2 Datatype2 NOT NULL,
column3 Datatype3 NOT NULL,
column4 Datatype4 ,
UNIQUE(columnname));
Example
CREATE TABLE Table_name(
EmpID Int NOT NULL,
Emp_Name Varchar(200) NOT NULL,
Address Varchar(200) NOT NULL,
Age int,
UNIQUE(EmpId));