How to set an auto-increment column in SQL Server?
In SQL Server, the way to set an auto-increment column is by using the IDENTITIY property when creating a table. For example:
CREATE TABLE ExampleTable
(
ID INT PRIMARY KEY IDENTITY(1,1),
Name VARCHAR(50)
)
In the example above, the ID column is set as an auto-increment column starting at 1 and increasing by 1 each time. When data is inserted into the table, the value in the ID column will automatically increment without the need for manual assignment. The IDENTIFY property can be used for columns of any integer data type, such as INT, BIGINT, etc.