Use [AdventureWorks]
GO
/****** object:storedprocedure [dbo]. [uspPrintError] Script date:04/10/2016 13:19:23 ******/
IF EXISTS (SELECT * from sys.objects WHERE object_id = object_id (N ' [dbo].[ uspPrintError] ') and type in (n ' P ', n ' PC '))
DROP PROCEDURE [dbo]. [uspPrintError]
GO
Use [AdventureWorks]
GO
/****** object:storedprocedure [dbo]. [uspPrintError] Script date:04/10/2016 13:19:23 ******/
SET ANSI_NULLS on
GO
SET QUOTED_IDENTIFIER ON
GO
--uspPrintError Prints error information about the error caused
--execution to the CATCH block of a TRY ... CATCH construct.
--should be executed from within the scope of a CATCH block otherwise
--It'll return without printing any error information.
CREATE PROCEDURE [dbo]. [uspPrintError]
As
BEGIN
SET NOCOUNT on;
--Print error information.
PRINT ' Error ' + CONVERT (varchar (), error_number ()) +
', Severity ' + CONVERT (varchar (5), error_severity ()) +
', state ' + CONVERT (varchar (5), error_state ()) +
', Procedure ' + ISNULL (error_procedure (), '-') +
', line ' + CONVERT (varchar (5), Error_line ());
PRINT error_message ();
END;
GO
EXEC sys.sp_addextendedproperty @name =n ' ms_description ', @value =n ' Prints error information about the error that caused ex Ecution to the CATCH block of a TRY ... CATCH construct. Should is executed from within the scope of a CATCH block otherwise it'll return without printing any error information. ', @level0type =n ' SCHEMA ', @level0name =n ' dbo ', @level1type =n ' PROCEDURE ', @level1name =n ' uspPrintError '
GO
"Backup" [AdventureWorks] [dbo]. [uspPrintError]