That has less to do which SP/XP you call, but with the raised error and it's severity
See TRY...CATCH (Transact-SQL) => Errors Unaffected by a TRY...CATCH Construct
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello! Is there a way to "try and catch" a system procedure like sys.xp_create_subdir. This command does not trigger our try and catch construct. Is there any solution for this? Thank you! Ceoolc
That has less to do which SP/XP you call, but with the raised error and it's severity
See TRY...CATCH (Transact-SQL) => Errors Unaffected by a TRY...CATCH Construct
TRY-CATCH and extended stored procedures is not a fantastic story. I have written about it here: http://www.sommarskog.se/error_handling/Part2.html#XPs
But I have not tried this particular XP.
It occurred to me that I describe some possible alternatives elsewhere in my series on Errors and Transaction Handling in SQL Server: http://www.sommarskog.se/error_handling/Part3.html#CMDcatchhandler
Not of these are very palatable. The least kludgy approach is probably the tip I got from Dave Mason, and which I discuss in the section after the one I linked you to. However, his approach does not work here: an error in an XP does not trigger the extended event. Bleech!
So that leaves you with my CMD Catch Handler. Or orchestrate what you want to do from a client-side program.