BEGIN TRY
— do stuff
END TRY
BEGIN CATCH
DECLARE @PROC AS VARCHAR(100)
DECLARE @SERVER AS VARCHAR(200)
DECLARE @ERROR AS VARCHAR(4000)
SELECT @PROC = ERROR_PROCEDURE(),
@SERVER = @@SERVERNAME,
@ERROR = ERROR_MESSAGE();
END CATCH;