Using the IDENTITYCOL Keyword : IDENTITYCOL « Sequence Indentity « SQL Server / T-SQL Tutorial






24> CREATE TABLE MyTable (
25>  key_col int NOT NULL IDENTITY (1,1),
26>  abc     char(1) NOT NULL
27> )
28> INSERT INTO MyTable VALUES ('a')
29> INSERT INTO MyTable VALUES ('b')
30> INSERT INTO MyTable VALUES ('c')
31>
32>
33> SELECT
34>  IDENTITYCOL,
35>  abc
36> FROM
37>  MyTable
38>
39>
40> drop table MyTable
41> GO

(1 rows affected)

(1 rows affected)

(1 rows affected)
key_col     abc
----------- ---
          1 a
          2 b
          3 c

(3 rows affected)








15.2.IDENTITYCOL
15.2.1.Using the IDENTITYCOL Keyword
15.2.2.SELECT IDENTITYCOL FROM yourTable