Question

Using SQL Server 2008 R2:

How can I write to the SQL Server Error Log? I have a ROLLBACK statement that I'd like to couple with a statement written to the error log for external monitoring.

Example:

BEGIN TRAN

INSERT INTO table1
SELECT * 
FROM table2

IF @@ERROR <> 0
BEGIN
    ROLLBACK TRAN
    --Write to log
    RETURN
END

COMMIT TRAN

EDIT:

I'd like to clarify - I want to write to the "SQL Server Logs", "Current" log, under the "Management" folder in the object explorer.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top