SQL Server does not allow explicit values to be inserted into it
1> -- SQL Server does not allow explicit values to be inserted into it
2>
3> CREATE TABLE MyTable (MyID Int IDENTITY(-1000000, 100) NOT NULL
4> ,MyDescription NVarChar(50) NOT NULL)
5>
6>
7> INSERT MyTable (MyID, MyDescription)
8> VALUES (5, 'This will not work')
9> GO
Msg 544, Level 16, State 1, Server JAVA2S\SQLEXPRESS, Line 7
Cannot insert explicit value for identity column in table 'MyTable' when IDENTITY_INSERT is set to OFF.
1>
2> select * from MyTable
3> GO
MyID MyDescription
----------- --------------------------------------------------
(0 rows affected)
1>
2> drop table MyTable
3> GO
1>
2>
Related examples in the same category