ALTER SERVER AUDIT (Transact-SQL)
Alters a server audit object using the SQL Server Audit feature. For more information, see Understanding SQL Server Audit.
ALTER SERVER AUDIT audit_name
TO { [ FILE ( <file_options> [, ...n] ) ] | APPLICATION_LOG | SECURITY_LOG }
[ WITH ( <audit_options> [, ...n] ) ]
}
| MODIFY NAME = new_audit_name
[ ; ]
<file_options>::=
{
FILEPATH = 'os_file_path'
[, MAXSIZE = { max_size { MB | GB | TB } | UNLIMITED } ]
[, MAX_ROLLOVER_FILES =integer | UNLIMITED } ]
[, RESERVE_DISK_SPACE = { ON | OFF } ]
}
<audit_options>::=
{
[ QUEUE_DELAY =integer ]
[, ON_FAILURE = { CONTINUE | SHUTDOWN } ]
[, STATE = = { ON | OFF } ]
}
You must specify at least one of the TO, WITH, or MODIFY NAME clauses when you call ALTER AUDIT.
You must set the state of an audit to the OFF option in order to make changes to an audit. If ALTER AUDIT is run when an audit is enabled with any options other than STATE=OFF, you will receive a MSG_NEED_AUDIT_DISABLED error message.
You can add, alter, and remove audit specifications without stopping an audit.
You cannot change an audit’s GUID after the audit has been created.
A. Changing a server audit name
The following example changes the name of the server audit HIPPA_Audit to HIPAA_Audit_Old.
USE master GO ALTER SERVER AUDIT HIPAA_Audit WITH (STATE = OFF); GO ALTER SERVER AUDIT HIPAA_Audit MODIFY NAME = HIPAA_Audit_Old; GO ALTER SERVER AUDIT HIPAA_Audit_Old WITH (STATE = ON); GO
B. Changing a server audit target
The following example changes the server audit called HIPPA_Audit to a file target.
USE master
GO
ALTER SERVER AUDIT HIPAA_Audit
WITH (STATE = OFF);
GO
ALTER SERVER AUDIT HIPAA_Audit
TO FILE (FILEPATH ='\\SQLPROD_1\Audit\',
MAXSIZE = 1000 MB,
RESERVE_DISK_SPACE=OFF)
WITH (QUEUE_DELAY = 1000,
ON_FAILURE = CONTINUE);
GO
ALTER SERVER AUDIT HIPAA_Audit
WITH (STATE = ON);
GO
