Friday

TRY..CATCH in T-SQL (sqlserver 2005)



SELECT * FROM sys.messages
ALTER Procedure usp_sp1
@XMLData XML
AS
BEGIN
DECLARE
...declarations...
SET XACT_ABORT ON
BEGIN TRY
BEGIN TRANSACTION usp_sp1_tran
...transactions...
COMMIT TRANSACTION usp_sp1_tran
END TRY
BEGIN CATCH
ROLLBACK TRAN usp_sp1_tran

DECLARE @ErrorMessage NVARCHAR(4000)
,@ErrorNumber INT
,@ErrorSeverity INT
,@ErrorState INT
,@ErrorLine INT
,@ErrorProcedure NVARCHAR(200) ;

SELECT @ErrorNumber = ERROR_NUMBER()
,@ErrorSeverity = ERROR_SEVERITY()
,@ErrorState = ERROR_STATE()
,@ErrorLine = ERROR_LINE()
,@ErrorProcedure = ISNULL(ERROR_PROCEDURE(), '-') ;


SELECT @ErrorMessage = 'Procedure:' + @ErrorProcedure + '; Line:'
+ CAST(@ErrorLine AS VARCHAR(10)) + '; ' + ERROR_MESSAGE() ;

--EXEC usp_Email @ErrorMessage, 'mymail@host.com'
RAISERROR ( @ErrorMessage, 16, 1 )
END CATCH
END


more...

No comments:

imagemagic add text to image

rem different types of text annotations on existing images rem cyan yellow orange gold rem -gravity SouthWest rem draw text and anno...