Insert questions into auto-enlarge column

How to insert data into a column that has been defined as an auto-increment column using insert with id? Please explain with an example.

+4
source share
1 answer

If you have an "auto-increment" column - you really shouldn't insert certain values ​​into this column yourself - after all, why is this an auto-increment column ....

If you must do this in the end, then you need to do:

SET IDENTITY_INSERT (your table name here) ON INSERT INTO (your table name here) (IdentityCol, OtherCol1, .....) VALUES( (new ID value), .......) SET IDENTITY_INSERT (your table name here) OFF 
+4
source

All Articles