![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Can any one give me any URL where I can find the locking Hint with example. I have a two query in one my stored procedure and in the that its returning session ID to users like. Set @SessionID = (Select TOP 1 SessionID from Session) UPDATE Session Set UsedYN = 1 where SessionID = @SessionID Select SessionID from Session What my concern is if any user call this stored procedure then it wont return the same session id to more than one user. What if I can rewrite the same query like that . set begin transaction Set @SessionID = (Select TOP 1 SessionID from Session (UPDLOCK) Where UserYN = 0) UPDATE Session Set UsedYN = 1 where SessionID = @SessionID Commit Transaction Can any guide gave his comments regarding above queries and I want to clear my locking concepts, I would really appreciate if any one send me the URL that contains this sort of example and locking HINT. Thanks in advance. |
#3
| |||
| |||
|
|
Can any one give me any URL where I can find the locking Hint with example. I have a two query in one my stored procedure and in the that its returning session ID to users like. Set @SessionID = (Select TOP 1 SessionID from Session) UPDATE Session Set UsedYN = 1 where SessionID = @SessionID Select SessionID from Session What my concern is if any user call this stored procedure then it wont return the same session id to more than one user. What if I can rewrite the same query like that . set begin transaction Set @SessionID = (Select TOP 1 SessionID from Session (UPDLOCK) Where UserYN = 0) UPDATE Session Set UsedYN = 1 where SessionID = @SessionID Commit Transaction Can any guide gave his comments regarding above queries and I want to clear my locking concepts, I would really appreciate if any one send me the URL that contains this sort of example and locking HINT. Thanks in advance. |
#4
| |||
| |||
|
|
What you are doing seems a bit odd... Using a TRANSACTION may help in your situation. However, you don't need to use any locking hints (such as UPDLOCK). By starting a TRANSACTION , the TRANSACTION is controlling the necessary locks. If you are experiencing serialization problems, you may wish to investigate the TRANSACTION ISOLATION LEVEL settings in Books Online. |
#5
| |||
| |||
|
|
Can any one give me any URL where I can find the locking Hint with example. I have a two query in one my stored procedure and in the that its returning session ID to users like. Set @SessionID = (Select TOP 1 SessionID from Session) |
![]() |
| Thread Tools | |
| Display Modes | |
| |