View Full Version : How do I simulate record locks on SQL Server?
planetmatt
10-09-2007, 07:02 PM
I am creating a script to monitor record locks on SQL Server but dont have any locks to test it with. How can I create some locked records?
quantumkev
10-09-2007, 07:59 PM
When you say "record locks", are you referring to records that are locked because someone is modifying them? If so, I would suggest creating a test script that includes an "UPDATE" statement on one or several records in a loop, with one of the values in the statement changing arbitrarily as the loop progresses. For example, you could create a field in a table called "test" that holds an integer, and simply update that field with the number of the loop iteration as it progresses. That way - because the record is being updated - it will be locked. Is this what you are talking about, or am I off track?
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.