A Way to Handle Raised Errors in Both Dynamic and Static SQL Code
If you've needed a reliable way to handle errors that might be raised in both dynamic and static SQL code, here is what I've been doing: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Erland Sommarskog - http://www.sommarskog.se/error_handling_2005.html -- Create date: 2009/11/29 -- Description: **Call this sp from within your -- CATCH block** This -- reraises/throws the most recent -- error. Please see -- http://www.sommarskog.se/error_handling_2005.html -- for more details. -- -- Modifications: -- Author: A. Jackson -- Create date: 2010/03/11 -- Description: Renamed the sp from -- "error_handler_sp" to -- "dba_Error_Handler" to conform -- to naming conventions. -- : Documented this sp. -- : Enhanced SQL readability. -- Author: