Insert an autonumber field on SQL Server


Written on February 2, 2008 – 4:25 pm | by André Gomes

Thanks David for your comment on my post.

Now i want to rectify the tip i give to you yesterday.

The best way to make an autonumber field is the Identity ”process” - which i didn’t know… is:

CREATE TABLE Users(

Id Identity(1,1),

Name nvarchar(50),

Email nvarchar(50),

)
INSERT INTO Users(Name, Email)
           VALUES ('Andre', 'aslgomesATgmailDOTcom')

The Identity sintax is: Identity(value start,increment).

More at: MSDN - Identity



Veja também:

Tags: , , ,

Post a Comment