TRY...CATCH not work when process include linked server - by zjcxc.邹建

Status : 

 


2
0
Sign in
to vote
ID 331635 Comments
Status Active Workarounds
Type Bug Repros 0
Opened 3/5/2008 1:56:37 PM
Access Restriction Public

Description

when I write a sql to execute some sql on a linked server, i found a problem, if sql(execute on linked server) include output parameter, and include "SET NOCOUNT ON" and "USE Database", if error occur, can't get this error on catch range
Sign in to post a comment.
Posted by Umachandar [MSFT] on 1/18/2013 at 4:48 PM
Hello,
We won't be able to address this request anytime soon. So I am closing this request.

--
Umachandar, SQL Programmability Team
Posted by Sara [MSFT] on 3/10/2008 at 6:46 PM
Hello

Thanks for reporting this issue. By design, TRY...CATCH will not handle the divide-by-zero error on the linked server. This is because a TRY…CATCH block on the local server will only handle batch abort and transaction abort errors on the linked server; statement abort errors on the remote side will not invoke the CATCH block on the local side. The divide-by-zero error in your example is a statement abort error and therefore will not invoke the CATCH block. SQL Server Books Online topic 'Handling Errors in Server-to-Server Remote Stored Procedures' has more details on this behavior.

Having said that, the behavior you are seeing may be incorrect since the error seems to be getting caught depending on the commenting of certain statements. We're currently looking into this and will have more information shortly.

Thank you.

-- SQL Server Relational Engine Team