SQL Server > Table

Auto-Increment with initial value script in SQL Server

How to specify auto increment and initial value to the new auto increment column from the code in SQL Server?

To specify see value and increment value to the auto increment column in the existing database table, we pass parameter to the IDENTITY.

The 1st parameter is the initial value and the 2nd parameter is the step value.

Alter table PersonalDetails
Add AutoId int NOT NULL IDENTITY (1, 5)

In this case, the 1st row AutoId value will be 1 and 2nd row AutoId value will be 6 and so on as the increment parameter is 5.

 Views: 2086 | Post Order: 18

Write for us