How to get column name and value while inserting error record in sql server?
Answers
Answered by
0
Try to do it like this for capturing the recent error and log that.
USE AdventureWorks2012;
GO
BEGIN TRY
-- Generate a divide-by-zero error.
SELECT 1/0;
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;
END CATCH;
GO
Similar questions
Science,
7 months ago
Computer Science,
1 year ago