Applies To: SQL Server 2014, SQL Server 2016 Preview
Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).
Adds a user-defined audit event to the USER_DEFINED_AUDIT_GROUP. If USER_DEFINED_AUDIT_GROUP is not enabled, sp_audit_write is ignored.
Applies to: SQL Server (SQL Server 2012 through current version).
A. Creating a user-defined audit event with informational text
The following example creates an audit event with the id 27, the succeeded value of 0, and included optional informational text.
EXEC sp_audit_write @user_defined_event_id = 27 , @succeeded = 0 , @user_defined_information = N'Access to a monitored object.' ;
B. Creating a user-defined audit event without informational text
The following example creates an audit event with the id 27, the succeeded value of 0, and does not include optional informational text or the optional parameter names.
EXEC sp_audit_write 27, 0;