4> CREATE TABLE MyTable (MyID Int IDENTITY(1, 10) NOT NULL
5> , MyDescription nVarChar(50) NOT NULL)
6>
7> INSERT MyTable (MyDescription) VALUES ('Auto Record 1')
8> INSERT MyTable (MyDescription) VALUES ('Auto Record 2')
9>
10> SET IDENTITY_INSERT MyTable ON
11>
12> INSERT MyTable (MyID, MyDescription) VALUES (5, 'Manual Record 1')
13>
14> SET IDENTITY_INSERT MyTable OFF
15>
16> INSERT MyTable (MyDescription) VALUES ('Auto Record 3')
17>
18> SELECT * FROM MyTable
19> GO
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
MyID MyDescription
----------- --------------------------------------------------
1 Auto Record 1
11 Auto Record 2
5 Manual Record 1
21 Auto Record 3
(4 rows affected)
1>
2> SELECT @@IDENTITY AS LastIdentity
3> GO
LastIdentity
----------------------------------------
21
(1 rows affected)
1> drop table MyTable;
2> GO