Groups | Blog | Home
all groups > sql server new users > february 2006 >

sql server new users : How to lock a table?


Jens
1/31/2006 11:27:59 PM
You can manually escalate the lock level to TABLOCK by specifying the
lock level after the object queried for.

HTH, Jens Suessmeyer.
Tom Moreau
2/1/2006 12:00:00 AM
If you truly are going to drop the original table, then the standard
TABLOCKX won't do it. Consider using an application lock, though the rest
of the application would have to be modified to respect the lock.

--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
..
[quoted text, click to view]
I have a table that I need to do a whole lot of manipulations to in a
stored procedure, including copying a whole bunch of it elsewhere,
dropping the original table and then recreating it.

The process takes about three minutes. During this time, I want to stop
any other users attempting to access that table.

Is there a simple way of manually ensuring that the table is locked?
Xmas
2/1/2006 12:00:00 AM
I have a table that I need to do a whole lot of manipulations to in a
stored procedure, including copying a whole bunch of it elsewhere,
dropping the original table and then recreating it.

The process takes about three minutes. During this time, I want to stop
any other users attempting to access that table.

AddThis Social Bookmark Button