Dela via


View a SQL Server Audit Log

This topic describes how to view a SQL Server audit log in SQL Server 2012 by using SQL Server Management Studio or Transact-SQL.

In This Topic

  • Before you begin:

    Security

  • To view a SQL Server audit log, using:

    SQL Server Management Studio

    Transact-SQL

Before You Begin

Security

Permissions

Requires the CONTROL SERVER permission.

Arrow icon used with Back to Top link [Top]

Using SQL Server Management Studio

To view a SQL Server audit log

  1. In Object Explorer, expand the Security folder.

  2. Expand the Audits folder.

  3. Right-click the audit log that you want to view and select View Audit Logs. This opens the Log File Viewer – server_name dialog box. For more information, see Log File Viewer F1 Help.

  4. When finished, click Close.

Arrow icon used with Back to Top link [Top]

Using Transact-SQL

To view a SQL Server audit log

  1. In Object Explorer, connect to an instance of Database Engine.

  2. On the Standard bar, click New Query.

  3. Copy and paste the following example into the query window and click Execute.

    -- Reads from a file that is named \\serverName\Audit\HIPPA_AUDIT.sqlaudit 
    SELECT * FROM sys.fn_get_audit_file ('\\serverName\Audit\HIPPA_AUDIT.sqlaudit',default,default);
    GO
    

For more information, see sys.fn_get_audit_file (Transact-SQL).

Arrow icon used with Back to Top link [Top]