Abdul
Abdul

Reputation: 2120

Clear logs from SQL Server Audit File

Is it possible to Clear SQL Server Audit File logs. I want to delete old logs by date but can't find a way to delete it both from interface and sql Query.

enter image description here

Upvotes: 0

Views: 6579

Answers (2)

Husam Abu-Oshaibah
Husam Abu-Oshaibah

Reputation: 1

Make sure that file is not in use by:

  • Right clicking the audit, then disabling it
  • Stopping all tools that are reading from that file

Then from properties, you can limit number of files and max number of lines inside each audit log file.

Upvotes: 0

ahmed abdelqader
ahmed abdelqader

Reputation: 3568

Yes, it is.

By sys.server_audits select old names via create_date column.

Then loop the names and delete them by using the next code for deleting:

ALTER SERVER AUDIT [Audit_name] WITH (STATE = OFF)
GO
USE [master]
GO
DROP SERVER AUDIT [Audit_name]
GO

Upvotes: -1

Related Questions