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 |
|
malawneh
Starting Member
24 Posts |
Posted - 2007-04-24 : 19:39:31
|
| Just a question. I believe that when using the TRY-CATCH that every CATCH Step is processed regardless of success of the try. Is this true? So I can commit a transaction in the CATCH?BEGIN TRY BEGIN TRANSACTION INSERT INTO SomeTableEND TRYBEGIN CATCH IF (XACT_STATE()) = -1 BEGIN ROLLBACK TRANSACTION SELECT @SaveStepNumber = @SaveStepNumber , @ErrorTypeID = 3 , @WPIType = '' RETURN ERROR_NUMBER() END IF (XACT_STATE()) = 1 BEGIN COMMIT TRANSACTION SELECT @SaveStepNumber = @SaveStepNumber , @ErrorTypeID = 0 , @WPIType = '' RETURN 0 ENDEND CATCHMichael Alawneh, DBA |
|
|
cvraghu
Posting Yak Master
187 Posts |
Posted - 2007-04-24 : 19:52:02
|
| No. From BOL - If there are no errors inside the TRY block, control passes to the statement immediately after the associated END CATCH statement. |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-04-24 : 19:59:38
|
that would indeed be a useless coding construct, if the catch was stepped into regardless of errors in the try block! www.elsasoft.org |
 |
|
|
malawneh
Starting Member
24 Posts |
Posted - 2007-04-24 : 20:04:31
|
| Thank you all.Michael Alawneh, DBA |
 |
|
|
|
|
|