1

I have a SQL Server 2008 database that contains a table of Items. Many users are viewing Items and can choose at any time to check out an available Item. I want to have a simple locking scheme where the user clicks an Item, the server then acquires a ROWLOCK, checks if the item is checked out already (reads the row), checks it out if available (updates the row), and then frees up the lock.

I have not been able to find any code examples showing how to do this completely. Most examples focus on a single statement, not multiple statements.

2
  • Maybe you can read stackoverflow.com/questions/3767328/how-to-perform-a-row-lock but i'm not sure it will work... Commented Mar 9, 2012 at 21:16
  • I read that, but it only covers a single statement. How do I ensure that the lock persists through the entire transaction? Commented Mar 9, 2012 at 21:18

1 Answer 1

0

I don't think it's possible.

sql rowlock on select statement

at work, we do that through a program that runs on the server.

All requests go through this program.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.