سؤال

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.

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى dba.stackexchange
scroll top