General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Creating unique record ID's
Hi
I need to be able to create unique record ID's and return the new ID to the calling procedure; what's the easiest and most effective way of doing this? Ideally I'd like to do everything from a generic stored procedure with SQL.
Here's what I do at the moment:
I have a table called SystemTable with 2 main fields, SystemTable.Table_Name and SystemTable.Table_Counter. For every table in my application there's a corresponding record within SystemTable which holds the next available record ID for that table. I can pass in the table name, SystemUsers for example, and my procedure will return the next available ID that I can use for that table. I can then perform an SQL Insert and explicitly tell the command the new record ID that I wish to use.
Is there an easier way to do this? As long as the procedure returns the unique record ID then I'm happy.
Regards
Derek
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only