Locking a table in sqlserver 2000
-
Hi, I am writing a stored procedure. I want to update the records in a table. till i complete the updation of records I want to lock the table and once i complete the updation i want to release the lock on the table. during the process of updation of records i don't want any other methods to access this table. How to achieve this Regards, Uma
-
Hi, I am writing a stored procedure. I want to update the records in a table. till i complete the updation of records I want to lock the table and once i complete the updation i want to release the lock on the table. during the process of updation of records i don't want any other methods to access this table. How to achieve this Regards, Uma
It happens automatically. As soon as you start making changes the table will get locked until the transaction is completed. Since SQL Server will wrap each statement in its own transaction, if you are updating over several SQL statements use Begin Transaction at the start and Commit Transaction when successfully finished.
Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos