How to lock a SQL server 2008 table while I do a Select followed by Insert command
Posted on 2011-10-12
I need to connect to my SQL server 2008 database using my ASP script. I am not using stored procedures.
I would like to do a SQL Select command to select a value from a table then depending on the value I then need to do an Insert command to insert a new row. It is not relevant what the Select and Insert commands actually do as regards my question.
I would like to know how I can lock the table while I do the Select and Insert. During this period I DO NOT want the table to be read, updated or inserted. After my insert command I would like to unlock the table.