TRY CATCH with Linked Server in SQL Server 2005 Not Working

前端 未结 2 590
一生所求
一生所求 2021-01-13 17:54

I am trying to catch sql error raised when I execute a stored procedure on a linked server. Both Servers are running SQL Server 2005.

To prove the issue I have creat

相关标签:
2条回答
  • 2021-01-13 18:04

    This returns the error information locally:

    EXEC ('your.fullyqualified.storedprocname') AT YOUR_LINKED_SERVER;
    
    0 讨论(0)
  • 2021-01-13 18:19

    See Handling Errors in Server-to-Server Remote Stored Procedures:

    Calling RAISERROR with severity less than 20 from inside a remote stored procedure causes a statement abort error on the remote server. A TRY…CATCH construct on the local server handles remote batch abort errors only. If a remote stored procedure calls RAISERROR with severity less than 20 and the remote stored procedure is scoped within a TRY block on the local server, RAISERROR does not cause control to pass to the CATCH block of the TRY…CATCH construct. However, RAISERROR with severity 20 or greater on the remote server breaks the connection, and execution on the local server passes to the CATCH block.

    0 讨论(0)
提交回复
热议问题