How can a column in SQL table made as Identifier column

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 :

  1. Only one column in a SQL table can be defined with IDENTITY property.
  2. IDENTITY column can be defined on decimal , int , numeric , smallint , bigint or tinyint data type column.
  3. Default increment value is 1
  4. 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


Leave a Reply