By submitting my Email address I confirm that I have read and accepted the Terms of Use and Declaration of Consent.

By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.

You also agree that your personal information may be transferred and processed in the United States, and that you have read and agree to the Terms of Use and the Privacy Policy.

an easy interface for detailed auditing, which facilitates the tracking and logging of events in the SQL Server database engine.

Although a detailed description of how to implement an audit in SQL Server is beyond the scope of this article, the following steps provide an overview of the SQL Server Audit process:

Create a server audit that defines the target.

Create the necessary server and database audit specifications.

Enable the server audit and the specifications.

Read the events once they've been recorded in the target.

You can read the events in Windows Event Viewer if you configured your server audit to point to the Windows Security or Application event log. You can also use Log File Viewer in SSMS to view the Windows event logs or to view the audit binary files, if you configured your SQL Server audit to use files as your target. In addition, you can use the sys.fn_get_audit_file system function to retrieve the event data from the binary files.

Regardless of which target type you choose, SSMS makes the process of creating an audit quite simple in Object Explorer:

Create the server audit in the Audits subfolder of the Security folder.

Figure 1: An audit is made up of a server audit and one or more specifications.

Although you can't tell from Figure 2, the server audit in this case is configured to use binary files as the target, and the specifications are each configured to use the SCHEMA_OBJECT_CHANGE_GROUP action group. That means, for the server audit specification, events are raised for any CREATE, ALTER or DROP operations on server objects, such as dropping a principal; but for the database audit specification, events are raised for any CREATE, ALTER or DROP operations at the schema level, such as adding or altering a view.

If, based on these settings, we were now to run a simple CREATE TABLE statement and DROP TABLE statement against the AdventureWorks2012 database, we could view the results in the Log File Viewer, as shown in Figure 2 below. Notice that an event is shown for the DROP statement and one for the CREATE statement. The third event is related to the auditing operation itself.

Figure2: SQL Server Audit data includes details about each event included in the specifications.

Log File Viewer displays a variety of information about each event. It might be difficult to read here, but when you try SQL Server Audit for yourself, you'll see how easy it is to record and view information about how your database is being used. And if you're already using SQL Server Audit, you'll find that, for the most part, little has changed from SQL Server 2008 to 2012, except for a few added features. For example, you now have more ways to configure how the system reacts upon audit failure, and you can now create filters within a server audit, something not possible in 2008. But the basic functionality has remained unchanged.

Of course, when you implement SQL Server Audit, you must take into account a number of considerations not covered here, such as the security of your logged data, its impact on performance when auditing data and how audits are treated when attaching a database or creating a database mirror. But once you sort through these issues, you'll find the basic SQL Server Audit components are simple to implement, easy to manage and effective in auditing your database. Together, they help ensure data compliance and protection. So if you're still hanging onto SQL Trace and those other tools for auditing, now is as good a time as any to consider making the switch.

About the author:Robert Sheldon is a technical consultant and the author of numerous books, articles and training material related to Microsoft Windows, various relational database management systems, and business intelligence design and implementation. You can find more information at http://www.rhsheldon.com.

0 comments

Register

Login

Forgot your password?

Your password has been sent to:

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy