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 |
med
Starting Member
2 Posts |
Posted - 2007-09-07 : 10:18:09
|
What would happen if i created a transaction as follows in SQL SERVER 2005:begin transaction test1set lock_timeout 0select * from table1 with (UPDLOCK)and before commiting it the sql server crashed?Upon restart Would the transaction be rolled back and the lock released, or would the transaction still be open and hanging? |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-09-07 : 10:31:29
|
the transaction will be rolled back and the lock will be released.and your lock_timeout being set to 0 means that the select will return an error immediatly if it can't acquire an UPDLOCK_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
|
|
med
Starting Member
2 Posts |
Posted - 2007-09-07 : 10:36:43
|
Thanks,If the select fails will the transaction close itself?Will SQL Server eventually clear out open transactions? |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-09-07 : 10:45:01
|
you should handle commiting transaction yourself.use try ... catch blocks for error handling.if the error has high enough severity to prevent further code execution the transaction will be closed._______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
|
|
|
|
|