Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IF @@ERROR <> 0 ...
- DECLARE @ErrorCode INT
- INSERT INTO Table ...
- SET @ErrorCode = @@ERROR
- IF @ErrorCode <> 0
- BEGIN
- INSERT INTO ErrorLog (ErrorCode, Message)
- VALUES (@ErrorCode, 'The INSERT operation failed.')
- END
- RAISERROR ... WITH LOG
- xp_logevent {error_number, 'message'} [, 'severity']
- ALTER PROCEDURE [dbo].[StoreProcedureName]
- (
- parameters
- )
- AS
- BEGIN
- SET NOCOUNT On
- BEGIN TRY
- --type your query
- End Try
- BEGIN CATCH
- SELECT
- ERROR_NUMBER() AS ErrorNumber,
- ERROR_SEVERITY() AS ErrorSeverity,
- ERROR_STATE() AS ErrorState,
- ERROR_PROCEDURE() AS ErrorProcedure,
- ERROR_LINE() AS ErrorLine,
- ERROR_MESSAGE() AS ErrorMessage
- RETURN -1
- END CATCH
- End
Add Comment
Please, Sign In to add comment