Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Blocks within Try catch Block

$
0
0

I am pretty sure i know the answer to this but before giving up on using Try Catch I would like verification.

The MSDN article on Try Catch states:

A TRY…CATCH construct cannot span multiple batches. A TRY…CATCH construct cannot span multiple blocks of Transact-SQL statements. For example, a TRY…CATCH construct cannot span two BEGIN…END blocks of Transact-SQL statements and cannot span an IF…ELSE construct.

I presume that means you can't have a try catch around multiple While blocks.

Is there a workaround past this restriction like maybe including a try catch inside the while block which will raise an error to an outer try catch block to rollback a transaction?  I really hate the idea of having to use theif @@error ... technique from SS 2000 if there is another way.


Edward R. Joell MCSD MCDBA



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>