SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Table lock
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Beginer2012
Starting Member

45 Posts

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

Thank you

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3328 Posts

Posted - 07/16/2012 :  09:35:31  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000