Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Table lock

Author  Topic 

Beginer2012
Starting Member

45 Posts

Posted - 2012-07-16 : 09:29:50
Hello,
How can I lock a table to prevent user from reading it while deleting and inserting records ?

Thank you

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-07-16 : 09:35:31
begin tran
select * from tbl with (tablockx, holdlock) where 1=0
....


commit tran



==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -