Core component of SQL Server for storing, processing, and securing data
In SQL Server Audit, the action_id column in the audit log is a varchar(4), not an int. To filter out specific actions such as SELECT, EXECUTE, and VIEW in a database audit specification, use the audit action names and their corresponding action_id values from sys.dm_audit_actions, and filter on the character action_id (not by converting it to int).
General approach:
- Find the
action_idvalues for the actions to exclude:SELECT action_id, name FROM sys.dm_audit_actions WHERE name IN ('SELECT', 'EXECUTE', 'VIEW DEFINITION'); - Use those
action_idvalues in the audit predicate or in queries against the audit log, for example:SELECT * FROM sys.fn_get_audit_file('your_audit_path', NULL, NULL) WHERE action_id NOT IN ('SLCT', 'EX', 'VWDF'); -- sample IDs; use actual values from step 1
Key points:
-
action_idin the audit log and insys.dm_audit_actionsisvarchar(4)and should be compared as text. - Use
sys.dm_audit_actionsto map between the human-readable action name (SELECT,EXECUTE,VIEW DEFINITION, etc.) and theaction_idused in audit records. - Do not convert
action_idtointfor filtering; that breaks the match and causes the filter to fail.
References: