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 |
|
Kaunda
Starting Member
7 Posts |
Posted - 2009-09-23 : 07:53:39
|
| At times we have deadlock problems in our production environment, it's not often but it happens once or twice a month or so.We have tried to find the lock problem in our code but so far without success, we do however suspect a transaction in our system which contains select statments as well as update statements. It is a rather long transaction.- Does anyone know how SQL Server locks records in the database when a transaction has been started?- Does it start the lock as soon as the transaction starts? or is the lock started when the transaction runs the update/delete statements?- Does it lock out all other users that tries to access the same database, the same record, the same extent? or how does it work?Any assistance is greatly appreciated!Regards,Kaunda |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2009-09-23 : 08:47:44
|
| This will explain locking for you:http://msdn.microsoft.com/en-us/library/aa213039(SQL.80).aspx |
 |
|
|
Kaunda
Starting Member
7 Posts |
Posted - 2009-09-23 : 09:48:45
|
| Thanks RickD, I have looked at the information on the provided page but I still don't understand it.What happens if the application starts the same transaction for several users at pretty much the same time. In this case it is the same transaction (the same piece of code) but the transactions access differens rows in the tables. User A wants to update Customer 500, user B wants to update Customer 600 etc.Should they lock each other out just because a transaction starts? or do they lock each other out only if the access the same information?/Kaunda |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2009-09-23 : 10:26:02
|
| Generally only if they access the same information, but it depends on the type of locking you are using. |
 |
|
|
|
|
|