Original Post
Hi! I have a few (three) SQL statements that I need to run to completion before another user starts running the same three statements. The first checks for availability in the database and I want to return early if the db has been updated (by the two last statements). Let's say I have products in a table, and they have a quantity. The first of the three statements checks the quantity, and if there are any products left, runs the two other statements to buy this product, thus reducing the quantity. But I need all other users to have to wait before they can run these statements if they are currently being run by someone, so that two users cannot run the first statement at the same time and believe that there are two products left, even though there is only one. I think I should use table locking for this but it is unclear exactly how. I have SQL Server 2005 and ADO.NET at my disposal. Can you help me? Thanks!