What is Auto Increment/ Identity column in SQL Server?

An Auto Increment/Identity column in SQL Server is a column that automatically generates a unique value for each new row inserted into a table. It is often used as a primary key to ensure each record has a distinct identifier. The column's value increments by a specified increment (default is 1) for each new row, guaranteeing uniqueness and simplifying data management.

Auto-increment allows a unique number to be generated automatically when a new record is inserted into a table.

Mostly auto increment is set on the primary key only.

CREATE TABLE Employee (

    ID int IDENTITY(1,1) PRIMARY KEY,

    EmpName varchar(255NOT NULL

);

 

Post a Comment

Previous Post Next Post