Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have to do series of select statements and do some calculations. Based on the calculations i would like to update a table. If i have them done in a Transaction does that mean that the particular table is locked till it is committed or rolled back. Will the second user be able to do same transaction simultaneously. Please do help me out as i am confused in this issue.

 

Thanks.

  • *Experts*
Posted

The locking during a SELECT depends on your isolation level. Look at the command "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE" (or the other 3 types of locking) for more info.

 

You can also add the (NOLOCK) optimizer hint to your select, as in:

SELECT * FROM Table1 (NOLOCK) INNER JOIN Table2 (NOLOCK) ON Table1.Col1 = Table2.Col2

 

Depending on the database locking, your update may lock a row or the table. SQL Server defaults to Row-Level locking (I think) so you should be Ok there, but you should probably read a few pages of the Transact SQL Help (under Query Analyzer's Help menu - easier than using Books Online sometimes).

 

-Ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...