Is there a command/SQL query to lock a particular table in MS SQL Server to stop all related transactions using ODBC?
+1
A:
Use the table hints, such as:
SELECT * FROM MyTable WITH (TABLOCK, HOLDLOCK)
See Table Hints in Books Online for more details.
_J_
2009-10-28 10:00:20
The TABLOCK hint is used to request a shared lock. You will most likely want to use TABLOCKX in order to obtain an exclusive lock.
John Sansom
2009-10-28 14:11:14