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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SP Help - Generate unique row ID's every time SP is executed

Status
Not open for further replies.

R000k

Programmer
Nov 9, 2010
5
GB
Hello,

I'm having some issues figuring out how to get this piece of code accomplished.

I need to manually create a 10 digit ID number that will continually increase every time the stored procedure is executed.

For instance:


This is my result set the first time I execute my SP:


ID Employee_Name
---- ---------------------
1111111111 Michael Jordan
1111111112 Larry Bird
1111111113 Magic Johnson
1111111114 John Stockton
1111111115 Charles Barkley
1111111116 David Robinson


This is the result set the next time the SP is executed:

ID Employee_Name
---- ---------------------
1111111117 Michael Jordan
1111111118 Larry Bird
1111111119 Magic Johnson
1111111120 John Stockton
1111111121 Charles Barkley
1111111122 David Robinson


I know I need to store the ID's somehow but I cannot figure out how to get this started. Any help would be greatly appreciated.

Thank you,

Mike
 
Make the id field a 10 digit identity field and then seed the identity to 1,000,000,000 (or whatever).


eg
SQL:
create table TBL (ID decimal(10) not null identity, 
                  name varchar(30))
GO;
dbcc checkident (TBL, RESEED, 1000000000)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top