Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lockinging a table

Status
Not open for further replies.

tek1ket

MIS
Jan 25, 2009
70
IR
how can i lock a table when inserting a record in it?
 
If you want to simulate a record lock in SQL Server you can try this technique described by Sergey Berezniker at another forum:
Code:
-- Will hold a lock on a record until COMMIT is issued. Exec 1 line at a time in SMSS


BEGIN TRANSACTION

SELECT SomeColumn FROM dbo.MyTable WITH (TABLOCKX) WHERE SomeCriteria

(Now run application code against locked record)

COMMIT  -- Releases lock
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top