Is it possible to do an explicit shared lock on a table in SQL Server?
I need to do the following:
- shared lock table
- copy table to temp table, for manipulation
- exclusive lock table
- copy stuff from tempTable to table
- release all locks
Basically, I want to be sure that nothing is added to the table, while I'm doing stuff to the temp table, but I still want it to be readable.
For some reason, putting the whole thing in a transaction causes a deadlock in some of the stuff I do to the temp table, so that is not an option.