IDENTITY property
Identified column can be implemented using IDENTITY property. While specifying IDENTITY column, you specify SEED and ARGUMENT.
SYNTAX :
IDENTITY [ (seed , increment) ]
When inserting rows into table with IDENTITY column , SQL Server automatically generates next identity value by adding increment to previous identity value.
FACTS :
- Only one column in a SQL table can be defined with IDENTITY property.
- IDENTITY column can be defined on decimal , int , numeric , smallint , bigint or tinyint data type column.
- Default increment value is 1
- Identity value is assigned in ascending order by default
EXAMPLE :
1. Create a table with IDENTITY column using create table script
CREATE TABLE Employee
(
EmpNumn int IDENTITY(1,1),
Name varchar (200),
Email varchar(100)
);
2. Identity column using SQL Server Enterprise Manager