Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. SQL Server
  3. Question
SQL Server

SQL Server TRY/CATCH does not work in certain cases

Asked by Anna Ball Apr 24, 2021 8 views 1 answer
Share

About this question

How can I write guarded code that invokes the CATCH code block in every expected* case (without doing any funky junk like wrapping everything in dynamic SQL)? For example, this does not work: Define a SQL Agent job with no steps Try to start the job inside a TRY/CATCH

Note that its error severity is 16 so it should not have bypassed the CATCH block. wtf?!?It also bypasses my CATCH block if the job is busy handling a request (I'm spamming stop and start requests in my testing).


Your answer

1 Answer

More SQL Server discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest SQL Server Blogs

Guides, tips and career advice on SQL Server from JanBask experts.