March 7, 2011 at 6:01 am
Hi,
Can anyone tel How to find the Locked rows in a table .
or to determine whether a row is locked or not.
I got Stuck in Sql script where i need to use the row level locks for selected rows in a table.
I want to use Row Locks on a table in a Transaction Code
Can anyone tell how to implement/use Row level Locks on a table in a Transaction, so that other users cannot access that row untill the transaction is completed.
Begin Transaction
lock the rows
do the calculations and update other tables
release the lock
Commit Transaction
Struggling with this issue since 3 days.
Any Help will be grately appreciated.
Please help me in this.
Thanks
Lakshman
March 7, 2011 at 2:30 pm
Honestly, that's a bad approach and will lead to problems. Best to let SQL Server handle locking for you. It will absolutely handle it well. If you have to, set the isolation level to SERIALIZABLE for this query, but even that approach may lead to issues.
You can use a table hint to force locks within the query, but this can be very, very problematic. Especially opening locks like that, performing multiple different updates, and then releasing the locks... you're looking at some serious performance bottlenecks and issues in the future.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply