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.
Author |
Topic |
sguerra
Starting Member
3 Posts |
Posted - 2005-09-23 : 19:41:58
|
I need to know how does sql server locks the rows of a select.With a statement like this:**************************************BEGIN TRANselect max(numero_reg)from cont_registro with (holdlock,rowlock) where serial_dia = 15//// do my stuffCOMMIT TRAN**************************************Is sql server locking all the rows of the where clause "where serial_dia = 15"ORIs sql server locking ONLY one row that complies whit"max(numero_reg)" and has "serial_dia = 15"Please helpSantiago G. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-09-23 : 19:44:14
|
You should begin tran until after your SELECT statement. All data gathering should be outside of the transaction. SQL Server starts at row-level locking and escalates as needed. You can read all about locking in SQL Server Books Online if you need detailed information about it.Tara |
 |
|
sguerra
Starting Member
3 Posts |
Posted - 2005-09-23 : 19:48:24
|
Could you be more specific (like an example), since I have read a lot of information about locking and i don't understand it very well.What i need is to lock all rows from table cont_registro that have serial_dia = 15.Santiago G. |
 |
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
|
|
|
|