Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select ..FOR UPDATE is to Oracle as _____ is to SQLServe
Message
From
17/02/1999 08:57:34
 
 
To
17/02/1999 02:50:39
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00187943
Message ID:
00188343
Views:
18
>The idea is only when updating..
>edit button clicked...
>BEGIN TRANSACTION
>Call the function to lock...(Via SELECT for update ect..)
>Make update statement....and update record..
>END (COMMIT) TRANSACTION

If you only want a lock applied when you update the row, SQL Server will do this naturally. Unless you override the basic behavior, SQL Server will place an exclusive lock on the row or page before making the change. The exclusive lock will be held until the end of the transaction.

BEGIN TRANSACTION
UPDATE table SET column = value WHERE ... -- SQL will acquire exclusive locks
-- Exclusive locks are still being held
COMMIT TRANSACTION -- Exclusive locks will be released.

You can see this for yourself using either the SQL Profiler or sp_lock (maybe sp_locks).

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform