views:

34

answers:

1

I need to know what keyword v should use for autoincrement in the table with primary key in sql 2005

+8  A: 

Identity

 CREATE TABLE blah(
     [ID] int IDENTITY PRIMARY KEY
 )
Hogan
+1, **IDENTITY (100,5)** to start at 100 and increment by 5, but I bet that is the default
KM
Default is seed = 1, increment = 1 ... so equivalent to above is [ID] INT IDENTITY(1,1) - though the PRIMARY KEY part is certainly not a required part of the syntax... you may just as easily want your PK on a column other than the IDENTITY column (as with many things, it depends).
Aaron Bertrand
@Aaron: Primary key need was part of the question :D
Hogan