Updating an identity column sql server

Another approach would be to add a new column and make it an identity column or add a new column without the identity property and migrate the data from the old column to the new column.

updating an identity column sql server-5

If we make this example a little more complicated, by having a primary key and creating a second table with a foreign key constraint referencing back to the first table we can see that even more work needs to be done.

It means that the first row, which was loaded into the table, will have the value of one, the second row will have the value of 2 and so on.

Suppose, you want the value of the identity column of the first row is 10 and incremental value is 10, you use the following syntax: column. If you insert a row into the identity column and the insert statement is failed or rolled back, then the identity value is lost and will not be generated again.

One nice feature of SQL Server that is used quite a bit is the use of identity columns.

This function gives you a simple way of creating a unique value for every row in your table.

Leave a Reply