Does BEGIN TRANSACTION do any row / column locks?

I am using a start transaction in my stored procedure. I have a code that updates data:

UPDATE
     employee
SET
     name = @name,
     surname = @surname
WHERE
     empId = @empid;

Does SQL Server support row lock or coloumn that is being updated? If this is not the case, how would I prevent other users from doing another update while the current update is in progress? This should not be in the stored procedure, C # is also an option.

+3
source share
3 answers

SQL Server creates locks on the objects that are accessed - and the lock becomes quite complicated in terms of what happens under the covers.

For your specific update statement, if one row is updated.

  • Row: , , .

  • : Intent Update, Intent Exclusive .

  • : Intent.

MS: http://msdn.microsoft.com/en-us/library/ms175519(v=sql.100).aspx

+3

if this is the only statement in sproc, then this is a transaction. Remember that each statement is atomic and either works or not, you do not need to worry about blocking.

0
source

All Articles