TPetersonFlorida
Programmer
I have a database that is used by an application where multiple people are writing to the database. I have one table that stores the next available part number, a sequential number. I need to write a stored procedure that gets that number, increments by one, then writes that new number back to the table for the next person. How do i lock this process so that if there are multiple calls to this stored procedure, only one executes at a time??
Here is my TSQL as of now:
Select @varNum = <PartNumber> From <MyTable>
Set @varNum = @varNum + 1
Update <MyTable> Set <PartNumber> = @varNum
The stored procedure will return @varNum.
Obviously the field name and table name are psuedo names.
Thanks in advance!
Here is my TSQL as of now:
Select @varNum = <PartNumber> From <MyTable>
Set @varNum = @varNum + 1
Update <MyTable> Set <PartNumber> = @varNum
The stored procedure will return @varNum.
Obviously the field name and table name are psuedo names.
Thanks in advance!