Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generating unique id numbers
Message
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00404882
Message ID:
00405317
Views:
17
I have code similar to this in a PK generator. To make sure, I wrap it in a transaction. I didn't want the the multi-threaded nature of SQL Server biting me.

>Hi:
>
>I'm using the following code fragment in an SP to generate unique case id numbers:
>
> update Counters set nxtcaseno = nxtcaseno + 1
> set @retval = (select nxtcaseno from Counters)
>
>I've used code similiar to this in FoxPro for a long time without ever getting a duplicate. However, I'm using it in SQL Server for the first and wonder if it is safe enough? Should I wrap this into a manual transaction or is the implicit transaction good enough?
>
>Thanx,
>Charlie
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform