SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

How to read an audit file

By Evgeny Garaev,

The script reads data from audit files for a particular audit in a tabular form.

That is an answer for a question from our fellow member - https://www.sqlservercentral.com/Forums/1916789/Audting-User-Logins-How-might-you-do-it . But I have decided to share it because it may be useful for other members.

In order to use it you have to replace {NameOfYourAudit} with the name of the audit on your SQL Server instance. That audit must be a file target audit. You also can filter the events which you are interested in by uncommenting the where clause and changing {MyStatement}. You can apply your own filters as well, for example you can use: client_ip, application_name, server_principal_name, and many other fields for filtering. Apart from custom filtering you can apply the custom ordering by changing the order by clause.

You can find more information about sys.fn_get_audit_file on the Microsoft web site - https://docs.microsoft.com/en-us/sql/relational-databases/system-functions/sys-fn-get-audit-file-transact-sql

Total article views: 332 | Views in the last 30 days: 9
 
Related Articles
FORUM

Audit

Audit

BLOG

Server Audit Mystery 2: Filtering action_id gets Error Msg 25713

This post is, for the most part, a continuation of Server Audit Mystery 1: Filtering class_type gets...

FORUM

Report Builder Filter order the same as the actual model.

Report Builder Filter order the same as the actual model.

BLOG

Server Audit Mystery 1: Filtering class_type gets Error Msg 25713

The other day I ran into an odd problem trying to answer the following question on DBA.StackExchange...

FORUM

auditing

column level auditing using profiler

Tags
 
Contribute