The Wayback Machine - https://web.archive.org/web/20230810140752/https://www.geeksforgeeks.org/sql-server-identity/
Skip to content
Related Articles
Open In App
Related Articles

SQL Server Identity

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Identity column of a table is a column whose value increases automatically. The value in an identity column is created by the server. A user generally cannot insert a value into an identity column. Identity column can be used to uniquely identify the rows in the table.

Syntax:

IDENTITY [( seed, increment)]


Seed: Starting value of a column. 
      Default value is 1.

Increment: Incremental value that is 
added to the identity value of the previous 
row that was loaded. The default value 1.

Example 1:

Image

Table Content

Image

Note:

The ‘ID’ column of the table starts from 1 as the seed value provided is 1 and is incremented by 1 at each row.

Example 2:

Image

Table Content

Image

Note:

The ‘ID’ column of the table starts from 1 but is incremented by 2 as the increment value is passed as 2 while creating the ‘IDENTITY’ Column.

Last Updated : 21 Mar, 2018
Like Article
Save Article
Similar Reads