Set Identity_insert on -- allows the insertion of specified data on the self-increment column ID Insert into Values (1,'test') Set Identity_insert OFF -- turn off insert specified data on the self-increment column ID
Attention:
1.set Identity_insert is only valid for the current session.
2.set identity_insert table name on settings, you must display the specified ID, or insert the error. If INSERT into table_name values (' 111 ') will be an error.
Inserts the specified value to the self-increment ID. Error: " cannot insert an explicit value for the Identity column in table" When IDENTITY_INSERT is set to OFF .
The INSERT statement does not display the specified ID. Error: "You can specify an explicit value for the identity column in the table only if the column list is used and Identity_insert is on."
SQL Server self-increment ID inserts the specified data