Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie (oldie to Oracle) - Sequence

Status
Not open for further replies.

HobbyMan

Programmer
Sep 22, 2000
25
US
In oracle we had sequences (database object
that was an auto-incremented number) which
are very useful to build data for primary keys.

Is there such a thing in MS Sql Server?

I have search the online books but have not
found anything compatible. [sig][/sig]
 
HobbyMan, give your PK column an Integer datatype and specify it as an Identity column. The default start (seed) value is 1 and the default increment is 1.

When inserting, you don't need to reference the column at all (i.e. you don't need to call NextVal), as the server will automatically insert the new value.

Identity columns, in and of themselves, do not guarantee a unique number, but since you typically have a PK contstraint on that column, it will work out that way. [sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top