Please help me out

vellaima

Well-known member
Joined
Jan 29, 2003
Messages
109
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.
 
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 Analyzers Help menu - easier than using Books Online sometimes).

-Ner
 
Back
Top