Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 transactions and locking

Author  Topic 

ann06
Posting Yak Master

171 Posts

Posted - 2009-04-26 : 05:49:18
if i have a transaction similar to this

BEGIN TRANSACTION

UPDATE Customer
SET CustomerName=@Name
WHERE CustomerID=@CustID

UPDATE CustomerPhone
SET PhoneNumber=@Phone
WHERE CustomerID=@CustID
AND PhoneType=@PType

COMMIT TRANSACTION

Custormer table will be locked until CustomerPhone table finishes and the transaction is closed? or as soon the update on customer table finishes then the locks are released?

Thanks Team

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-04-26 : 05:51:35
Customer table will be locked until CustomerPhone table finishes and the transaction is closed.

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

ann06
Posting Yak Master

171 Posts

Posted - 2009-04-26 : 07:10:14
this is for for the default isolation level right?
what if the transaction had
Select * from customers
will locks also be place there until the finish of the trans? or only update, delete and insert statement will lock z tables for the end of the trans?
Go to Top of Page

ann06
Posting Yak Master

171 Posts

Posted - 2009-04-28 : 03:10:43
any help for the last reply?
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-04-28 : 03:51:30
To be sure what happens I advise you to do the following:
Open a query window
begin trans
do what you want to test...

do no commit / no rollback at this time...

open a second query window and test if it is possible to acces the data as you want

go back to first window and close trans

You can do your test this way because each window has its own session.
Hope that would help
Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -