<?xml version="1.0" encoding="iso-8859-1"?><!-- generator="b2evolution/4.0.3" -->
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>All Blogs - Author(s): SQLArcher</title>
		<link>http://blogs.lessthandot.com/index.php/All/</link>
		<atom:link rel="self" type="application/rss+xml" href="http://blogs.lessthandot.com/index.php/All/?tempskin=_rss2" />
		<description>LessThanDot A Technical Community for IT Professionals</description>
		<language>en-US</language>
		<docs>http://blogs.law.harvard.edu/tech/rss</docs>
		<admin:generatorAgent rdf:resource="http://b2evolution.net/?v=4.0.3"/>
		<ttl>60</ttl>
				<item>
			<title>The 5 minute guide to get started with Windows 8</title>
			<link>http://blogs.lessthandot.com/index.php/SysAdmins/windows-8/the-5-minute-guide-to</link>
			<pubDate>Mon, 10 Sep 2012 06:35:00 +0000</pubDate>			<dc:creator>SQLArcher</dc:creator>
			<category domain="alt">Operating Systems</category>
<category domain="main">Windows 8</category>			<guid isPermaLink="false">1824@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Windows 8 has been a hot topic of late - especially getting started with it. We already had a post from our very own Denis Gobo (&lt;a href=&quot;http://www.twitter.com/denisgobo&quot;&gt;@denisgobo&lt;/a&gt;) in &lt;a href=&quot;http://blogs.lessthandot.com/index.php/SysAdmins/windows-8/how-to-shutdown-windows-8&quot;&gt;how to shut down Windows 8&lt;/a&gt;. This led me to write a quick post on some features you may or may not know of.&lt;/p&gt;

&lt;p&gt;Windows 8 has a great design for touch screens, and some great shortcuts for the PC User as well. I&#039;ve been using it since Consumer Preview and to be honest - it did take a week or so to get used to the new interface. There are one or two tricks, that when you know them, make it a lot easier to work with as a PC User.&lt;/p&gt;

&lt;p&gt;To start of with, I am going to talk a bit about charms. Charms is the new &quot;navigation&quot; for Windows 8 - it appears on the right hand side whenever you move your mouse to either the top right, or bottom right corners of the screen.&lt;/p&gt;

&lt;p&gt;This will bring up the following:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/Charms_Menu.jpg?mtime=1347266235&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/Charms_Menu.jpg?mtime=1347266235&quot; width=&quot;270&quot; height=&quot;1079&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;In order they are:&lt;/p&gt;

&lt;p&gt;1. Search&lt;br /&gt;
2. Share&lt;br /&gt;
3. Windows 8 UI&lt;br /&gt;
4. Devices&lt;br /&gt;
5. Settings&lt;/p&gt;

&lt;p&gt;There is one thing about charms which is a very subtle yet powerful feature... it is context sensitive! Depending which application is active, will depend what charms enables you to do. Some of you might have downloaded the Wikipedia app (for example) from the store; good looking, side scrolling; so how do you search? With the charms menu, just open it up and search whatever you&#039;re looking for. For those of you which lives in a suffocated broadband area like me - this is also where you go to limit the amount of data which live tiles uses in the Win8UI (this however is only from RTM onwards).&lt;/p&gt;

&lt;p&gt;Another handy feature is Flip-2D - better known as the 3D Aero flip in Windows Vista/7. This is done by moving your mouse to the top left corner of the screen, or pressing WIN + Tab.&lt;/p&gt;

&lt;p&gt;It looks similar to this:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/QuickView.jpg?mtime=1347266256&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/QuickView.jpg?mtime=1347266256&quot; width=&quot;441&quot; height=&quot;524&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;When it is fully expanded it will look like this (this one is cropped, at the bottom you will have the link to the Win8UI):&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/QuickView_2.jpg?mtime=1347267039&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/QuickView_2.jpg?mtime=1347267039&quot; width=&quot;187&quot; height=&quot;374&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;A big question would be why to use this one instead of ALT + Tab? While ALT + Tab cycles through both the desktop apps and your Win8 apps, the WIN + Tab allows you to select an individual application and pin it either side of your screen directly if you do not want to close your active application. Apart from this, the only other difference is that it does not cycle through desktop applications.&lt;/p&gt;

&lt;p&gt;The last quick feature is the poweruser menu, which is accessible by right clicking on the Win8UI shortcut on the bottom left of the screen:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/PowerUser.jpg?mtime=1347266245&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/PowerUser.jpg?mtime=1347266245&quot; width=&quot;351&quot; height=&quot;395&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;This gives you quick access to control panel, command line, etc. which is very useful.&lt;/p&gt;

&lt;p&gt;The last most notable feature is Hyper-V which is available in Windows 8 Pro and Enterprise editions, with the limit being an x64 edition with a SLAT capable CPU. This is very handy especially when you build and destroy multiple virtual machines and do not want to install a Server edition on your Computer/Laptop or if you do not have access to a separate virtual environment. This is enabled via the add/program features.&lt;/p&gt;

&lt;p&gt;One last shortcut that I find extremely useful when working with SQL Server Data Tools, Management Studio, etc. is CTRL + Shift. When holding these two keys and launching an application from Win8UI, this immediately launches the application in Administrator Mode.&lt;/p&gt;

&lt;p&gt;If there is any features you find handy, feel free to leave a comment.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/SysAdmins/windows-8/the-5-minute-guide-to&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Windows 8 has been a hot topic of late - especially getting started with it. We already had a post from our very own Denis Gobo (<a href="http://www.twitter.com/denisgobo">@denisgobo</a>) in <a href="http://blogs.lessthandot.com/index.php/SysAdmins/windows-8/how-to-shutdown-windows-8">how to shut down Windows 8</a>. This led me to write a quick post on some features you may or may not know of.</p>

<p>Windows 8 has a great design for touch screens, and some great shortcuts for the PC User as well. I've been using it since Consumer Preview and to be honest - it did take a week or so to get used to the new interface. There are one or two tricks, that when you know them, make it a lot easier to work with as a PC User.</p>

<p>To start of with, I am going to talk a bit about charms. Charms is the new "navigation" for Windows 8 - it appears on the right hand side whenever you move your mouse to either the top right, or bottom right corners of the screen.</p>

<p>This will bring up the following:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/Charms_Menu.jpg?mtime=1347266235"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/Charms_Menu.jpg?mtime=1347266235" width="270" height="1079" /></a></div>

<p>In order they are:</p>

<p>1. Search<br />
2. Share<br />
3. Windows 8 UI<br />
4. Devices<br />
5. Settings</p>

<p>There is one thing about charms which is a very subtle yet powerful feature... it is context sensitive! Depending which application is active, will depend what charms enables you to do. Some of you might have downloaded the Wikipedia app (for example) from the store; good looking, side scrolling; so how do you search? With the charms menu, just open it up and search whatever you're looking for. For those of you which lives in a suffocated broadband area like me - this is also where you go to limit the amount of data which live tiles uses in the Win8UI (this however is only from RTM onwards).</p>

<p>Another handy feature is Flip-2D - better known as the 3D Aero flip in Windows Vista/7. This is done by moving your mouse to the top left corner of the screen, or pressing WIN + Tab.</p>

<p>It looks similar to this:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/QuickView.jpg?mtime=1347266256"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/QuickView.jpg?mtime=1347266256" width="441" height="524" /></a></div>

<p>When it is fully expanded it will look like this (this one is cropped, at the bottom you will have the link to the Win8UI):</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/QuickView_2.jpg?mtime=1347267039"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/QuickView_2.jpg?mtime=1347267039" width="187" height="374" /></a></div>

<p>A big question would be why to use this one instead of ALT + Tab? While ALT + Tab cycles through both the desktop apps and your Win8 apps, the WIN + Tab allows you to select an individual application and pin it either side of your screen directly if you do not want to close your active application. Apart from this, the only other difference is that it does not cycle through desktop applications.</p>

<p>The last quick feature is the poweruser menu, which is accessible by right clicking on the Win8UI shortcut on the bottom left of the screen:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/PowerUser.jpg?mtime=1347266245"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/Windows8Guide/PowerUser.jpg?mtime=1347266245" width="351" height="395" /></a></div>

<p>This gives you quick access to control panel, command line, etc. which is very useful.</p>

<p>The last most notable feature is Hyper-V which is available in Windows 8 Pro and Enterprise editions, with the limit being an x64 edition with a SLAT capable CPU. This is very handy especially when you build and destroy multiple virtual machines and do not want to install a Server edition on your Computer/Laptop or if you do not have access to a separate virtual environment. This is enabled via the add/program features.</p>

<p>One last shortcut that I find extremely useful when working with SQL Server Data Tools, Management Studio, etc. is CTRL + Shift. When holding these two keys and launching an application from Win8UI, this immediately launches the application in Administrator Mode.</p>

<p>If there is any features you find handy, feel free to leave a comment.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/SysAdmins/windows-8/the-5-minute-guide-to">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/SysAdmins/windows-8/the-5-minute-guide-to#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/SysAdmins/?tempskin=_rss2&#38;disp=comments&#38;p=1824</wfw:commentRss>
		</item>
				<item>
			<title>Moving On, Getting Converted...</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/moving-on-getting-converted</link>
			<pubDate>Tue, 13 Mar 2012 07:56:00 +0000</pubDate>			<dc:creator>SQLArcher</dc:creator>
			<category domain="main">Microsoft SQL Server Admin</category>			<guid isPermaLink="false">1662@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;After a great many years (3 to be exact) I&#039;m moving on from my current position into new exciting challenges. I have learned a lot in working in a big environment like this and swimming in the deep waters of SQL Server, but a huge thanks goes to my great colleagues and manager were able to keep up with my ramblings and (sometimes intolerable) drive for innovation and restraining me from torturing developers who have not yet learned the way of SQL Server.&lt;/p&gt;

&lt;p&gt;As of the 1st of April ( and no, it is not an April fools joke, I confirmed with HR ) I will be joining Microsoft South Africa as one of the Premier Field Engineers for SQL Server. This will be a very exciting challenge and great position for learning more about SQL Server in its various ways of implementation, and looking forward to work with my new team.&lt;/p&gt;

&lt;p&gt;But, moving to this position I&#039;m actually curious to know how many IT Professionals actually know about PFE&#039;s and the Premier Agreement for EA customers as a few of my friends down in South Africa wasn&#039;t aware of PA&#039;s which can contribute to special training called WorkshopPLUS. Feel free to comment if you don&#039;t know about this, or if you do have an agreement if you are making use of the various benefits and resources.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/moving-on-getting-converted&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>After a great many years (3 to be exact) I'm moving on from my current position into new exciting challenges. I have learned a lot in working in a big environment like this and swimming in the deep waters of SQL Server, but a huge thanks goes to my great colleagues and manager were able to keep up with my ramblings and (sometimes intolerable) drive for innovation and restraining me from torturing developers who have not yet learned the way of SQL Server.</p>

<p>As of the 1st of April ( and no, it is not an April fools joke, I confirmed with HR ) I will be joining Microsoft South Africa as one of the Premier Field Engineers for SQL Server. This will be a very exciting challenge and great position for learning more about SQL Server in its various ways of implementation, and looking forward to work with my new team.</p>

<p>But, moving to this position I'm actually curious to know how many IT Professionals actually know about PFE's and the Premier Agreement for EA customers as a few of my friends down in South Africa wasn't aware of PA's which can contribute to special training called WorkshopPLUS. Feel free to comment if you don't know about this, or if you do have an agreement if you are making use of the various benefits and resources.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/moving-on-getting-converted">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/moving-on-getting-converted#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1662</wfw:commentRss>
		</item>
				<item>
			<title>RedGate SQL Tab Magic</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/redgate-sql-tab-magic</link>
			<pubDate>Thu, 16 Feb 2012 10:10:00 +0000</pubDate>			<dc:creator>SQLArcher</dc:creator>
			<category domain="main">Database Administration</category>
<category domain="alt">Microsoft SQL Server Admin</category>			<guid isPermaLink="false">1643@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;After upgrading my SQL Toolbelt installation recently, I came across a new entry in the SQL Prompt menu that is integrated into SQL Server Management Studio. So I have decided to put out a quick post on one of the features which I find is handy.&lt;/p&gt;

&lt;p&gt;With the new SQL Toolbelt, I&#039;ve also installed the Redgate integration which integrates all the tools for you into Management Studio. On my way to make some changes to my configuration for SQL Prompt, I noticed the Experimental Features... portion which altered my curiosity setting to a full 100%.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/Menu.jpg?mtime=1329394384&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/Menu.jpg?mtime=1329394384&quot; width=&quot;282&quot; height=&quot;472&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;This results into the following screen with all its interesting beta programs,features,etc.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/redgate_labs.jpg?mtime=1329394405&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/redgate_labs.jpg?mtime=1329394405&quot; width=&quot;762&quot; height=&quot;633&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;After reading through the descriptions, SQL Tab Magic caught my attention the most as I regularly have multiple query tabs open within SSMS. After downloading and installing it, you will see the following toolbar set appear:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/toolbar.jpg?mtime=1329394414&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/toolbar.jpg?mtime=1329394414&quot; width=&quot;281&quot; height=&quot;26&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;This will show you(after the installation) all the closed or open query tabs with a portion of the query. For example:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/OpenTabs.jpg?mtime=1329394394&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/OpenTabs.jpg?mtime=1329394394&quot; width=&quot;773&quot; height=&quot;361&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;You can also through the toolbar, set it to look for new tabs and configure it to open any tabs on start up that you had open in a previous session.&lt;/p&gt;

&lt;p&gt;There are a few other labs as well which you can find at &lt;a href=&quot;http://labs.red-gate.com/&quot;&gt;RedGate Labs&lt;/a&gt; all though they don&#039;t feature SQL Tab Magic there.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/redgate-sql-tab-magic&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>After upgrading my SQL Toolbelt installation recently, I came across a new entry in the SQL Prompt menu that is integrated into SQL Server Management Studio. So I have decided to put out a quick post on one of the features which I find is handy.</p>

<p>With the new SQL Toolbelt, I've also installed the Redgate integration which integrates all the tools for you into Management Studio. On my way to make some changes to my configuration for SQL Prompt, I noticed the Experimental Features... portion which altered my curiosity setting to a full 100%.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/Menu.jpg?mtime=1329394384"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/Menu.jpg?mtime=1329394384" width="282" height="472" /></a></div>

<p>This results into the following screen with all its interesting beta programs,features,etc.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/redgate_labs.jpg?mtime=1329394405"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/redgate_labs.jpg?mtime=1329394405" width="762" height="633" /></a></div>

<p>After reading through the descriptions, SQL Tab Magic caught my attention the most as I regularly have multiple query tabs open within SSMS. After downloading and installing it, you will see the following toolbar set appear:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/toolbar.jpg?mtime=1329394414"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/toolbar.jpg?mtime=1329394414" width="281" height="26" /></a></div>

<p>This will show you(after the installation) all the closed or open query tabs with a portion of the query. For example:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/OpenTabs.jpg?mtime=1329394394"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/Redgate_SQLTabMagic/OpenTabs.jpg?mtime=1329394394" width="773" height="361" /></a></div>

<p>You can also through the toolbar, set it to look for new tabs and configure it to open any tabs on start up that you had open in a previous session.</p>

<p>There are a few other labs as well which you can find at <a href="http://labs.red-gate.com/">RedGate Labs</a> all though they don't feature SQL Tab Magic there.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/redgate-sql-tab-magic">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/redgate-sql-tab-magic#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1643</wfw:commentRss>
		</item>
				<item>
			<title>SQL Server Auditing: Looking Back</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-looking-back</link>
			<pubDate>Mon, 09 Jan 2012 08:00:00 +0000</pubDate>			<dc:creator>SQLArcher</dc:creator>
			<category domain="main">Database Administration</category>
<category domain="alt">Microsoft SQL Server Admin</category>			<guid isPermaLink="false">1585@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Over the past couple of weeks, we have looked at the new auditing feature introduced in SQL Server 2008. This post will finish up with the series and will cover the remaining subjects:&lt;br /&gt;
 &lt;br /&gt;
1.SQL Server 2008 vs. SQL Server 2012,&lt;br /&gt;
2.PBM - Last take on auditing your audits,&lt;br /&gt;
3.The Auditing Repository.&lt;/p&gt;


&lt;h3&gt;SQL Server 2008 vs. SQL Server 2012&lt;/h3&gt;

&lt;p&gt;The new release of SQL Server is around the corner, and with it there are numerous enhancements to the various components as well as new features. The auditing component is no different. There are a total of 507 audit actions in SQL Server 2012 compared to the 454 in SQL Server 2008 R2. Some of the new actions are more specifically geared to the new SQL Server 2012 Database Containment Feature.&lt;/p&gt;

&lt;p&gt;In addition to this, it also introduces filtering to your audits. This is set up on your audit instead of the Server Audit Specification or Database Audit Specification. This will limited what is written to the audit file even more, however there will be the additional CPU overhead to pay for filtering the audits.&lt;/p&gt;

&lt;p&gt;Let&#039;s take a look how to set it up through the SSMS:&lt;/p&gt;

&lt;p&gt;First of all, create the audit as previously and navigate as in the screenshot. Note that we will use testdb, check for dbo schema and only actions taking place by users which are defined as a DB_Owner:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/SQL2012_New/Filtered_Audit_GUI.jpg?mtime=1326103445&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/SQL2012_New/Filtered_Audit_GUI.jpg?mtime=1326103445&quot; width=&quot;602&quot; height=&quot;170&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;Next we define a Server Audit Specification to Capture Schema access:&lt;br /&gt;
&lt;em&gt;Note. This is necessary to capture the events. Previously a Server Audit Specification captured ALL the events across ALL databases.&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/SQL2012_New/Filtered_Audit_Spec_GUI.jpg?mtime=1326103453&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/SQL2012_New/Filtered_Audit_Spec_GUI.jpg?mtime=1326103453&quot; width=&quot;457&quot; height=&quot;135&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;To create the same audit using TSQL(which is easier) is as follows:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb21754&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;USE&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;master&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CREATE&lt;/span&gt; SERVER &lt;span style=&quot;color: #0000FF;&quot;&gt;AUDIT&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;Filtered&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;TO&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;FILE&lt;/span&gt; &lt;br /&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;FILEPATH&lt;/span&gt; = N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;E:\SQLAuditing\&#039;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; ,&lt;span style=&quot;color: #0000FF;&quot;&gt;MAXSIZE&lt;/span&gt; = &lt;span style=&quot;color: #000;&quot;&gt;10&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;MB&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; ,&lt;span style=&quot;color: #0000FF;&quot;&gt;MAX_FILES&lt;/span&gt; = &lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; ,&lt;span style=&quot;color: #0000FF;&quot;&gt;RESERVE_DISK_SPACE&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;OFF&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;WITH&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;QUEUE_DELAY&lt;/span&gt; = &lt;span style=&quot;color: #000;&quot;&gt;1000&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; ,&lt;span style=&quot;color: #0000FF;&quot;&gt;ON_FAILURE&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;CONTINUE&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;br /&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;database_name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;=&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;testdb&#039;&lt;/span&gt; AND &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;schema_name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;=&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;dbo&#039;&lt;/span&gt; AND &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_name&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;=&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;tab1&#039;&lt;/span&gt; AND &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;database_principal_name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;=&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;dbo&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ALTER&lt;/span&gt; SERVER &lt;span style=&quot;color: #0000FF;&quot;&gt;AUDIT&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;Filtered&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;WITH&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;STATE&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;USE&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;master&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CREATE&lt;/span&gt; SERVER &lt;span style=&quot;color: #0000FF;&quot;&gt;AUDIT&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;SPECIFICATION&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;Server_Spec_Filtering&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;FOR&lt;/span&gt; SERVER &lt;span style=&quot;color: #0000FF;&quot;&gt;AUDIT&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;Filtered&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ADD&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;SCHEMA_OBJECT_ACCESS_GROUP&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;WITH&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;STATE&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;OFF&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb46035&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Below is the results of querying an audit file with the filter:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/SQL2012_New/Filtered_Results.jpg?mtime=1326103463&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/SQL2012_New/Filtered_Results.jpg?mtime=1326103463&quot; width=&quot;732&quot; height=&quot;63&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;Other additional functionality is OnError:Fail Operation as well as maximum number of files. Maximum number of files indicates the number of files needed to be kept.&lt;/p&gt;


&lt;h3&gt;PBM - Last Take On Auditing Your Audits&lt;/h3&gt;

&lt;p&gt;Continuing from the last post, below is some policies which you can use with SQL Server 2008/R2/2012.&lt;/p&gt;

&lt;p&gt;They are as follows:&lt;br /&gt;
1. Audit files.&lt;br /&gt;
2. Database Audits.&lt;br /&gt;
3. Server Audits.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note. I included a ServerVersion condition if you intend to use this with the Enterprise Policy Framework. This will only execute the policies against SQL Server 2008 upwards.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;These policies will take a look at the naming convention for the policies as follows:&lt;/p&gt;

&lt;p&gt;Database Audits:&lt;/p&gt;

&lt;p&gt;1. Name starts with &#039;DBAudit_%.&lt;br /&gt;
2. Audit file name starts with &#039;DBAudit_Spec_%&#039;.&lt;br /&gt;
3. Audit is enabled.&lt;/p&gt;

&lt;p&gt;Server Audits:&lt;/p&gt;

&lt;p&gt;1. Name starts with &#039;SQLAudit_%&#039;.&lt;br /&gt;
2. Audit file name starts with &#039;ServerAudit_%&#039;.&lt;br /&gt;
3. Audit is enabled.&lt;/p&gt;

&lt;p&gt;Audit Files:&lt;/p&gt;

&lt;p&gt;1. Audit file is enabled.&lt;br /&gt;
2. Destination type is file.&lt;br /&gt;
3. 100 Maximum files.&lt;br /&gt;
4. 10 Roll over files&lt;br /&gt;
5. File size is maximum 5GB.&lt;br /&gt;
6. File size unit is GB.&lt;br /&gt;
7. Reserve disk space true.&lt;/p&gt;

&lt;p&gt;Below are the create conditions:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb35303&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;--- Audit_Condition&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @condition_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_condition&lt;/span&gt; @name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit_Condition&#039;&lt;/span&gt;, @description=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @facet=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit&#039;&lt;/span&gt;, @expression=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;OpType&amp;gt;AND&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;AND&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;AND&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;AND&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;AND&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;AND&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;Enabled&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;FunctionType&amp;gt;True&amp;lt;/FunctionType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ReturnType&amp;gt;Bool&amp;lt;/ReturnType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;0&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;DestinationType&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;FunctionType&amp;gt;Enum&amp;lt;/FunctionType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ReturnType&amp;gt;Numeric&amp;lt;/ReturnType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.String&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;Microsoft.SqlServer.Management.Smo.AuditDestinationType&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.String&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;File&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;MaximumFiles&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.Double&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;100&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;MaximumRolloverFiles&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.Double&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;10&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;MaximumFileSize&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.Double&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;5&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;MaximumFileSizeUnit&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;FunctionType&amp;gt;Enum&amp;lt;/FunctionType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ReturnType&amp;gt;Numeric&amp;lt;/ReturnType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.String&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;Microsoft.SqlServer.Management.Smo.AuditFileSizeUnit&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.String&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;Gb&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;ReserveDiskSpace&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;FunctionType&amp;gt;True&amp;lt;/FunctionType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ReturnType&amp;gt;Bool&amp;lt;/ReturnType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;0&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;lt;/Operator&amp;gt;&#039;&lt;/span&gt;, @is_name_condition=&lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;, @obj_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @condition_id=@condition_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @condition_id&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;--- DatabaseAudit_Condition&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @condition_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_condition&lt;/span&gt; @name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;DatabaseAudit_Condition&#039;&lt;/span&gt;, @description=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @facet=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;DatabaseAuditSpecification&#039;&lt;/span&gt;, @expression=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;OpType&amp;gt;AND&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;AND&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;LIKE&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;AuditName&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.String&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;DBAudit_%&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;LIKE&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;Name&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.String&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;DBAudit_Spec_%&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;Enabled&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;FunctionType&amp;gt;True&amp;lt;/FunctionType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ReturnType&amp;gt;Bool&amp;lt;/ReturnType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;0&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;lt;/Operator&amp;gt;&#039;&lt;/span&gt;, @is_name_condition=&lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;, @obj_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @condition_id=@condition_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @condition_id&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;--- ServerAudit_Condition&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @condition_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_condition&lt;/span&gt; @name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ServerAudit_Condition&#039;&lt;/span&gt;, @description=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @facet=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ServerAuditSpecification&#039;&lt;/span&gt;, @expression=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;OpType&amp;gt;AND&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;AND&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;LIKE&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;AuditName&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.String&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;SQLAudit_%&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;LIKE&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;Name&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.String&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;ServerAudit_%&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;Enabled&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;FunctionType&amp;gt;True&amp;lt;/FunctionType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ReturnType&amp;gt;Bool&amp;lt;/ReturnType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;0&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;lt;/Operator&amp;gt;&#039;&lt;/span&gt;, @is_name_condition=&lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;, @obj_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @condition_id=@condition_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @condition_id&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;---ServerVersion&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @condition_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_condition&lt;/span&gt; @name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ServerVersion&#039;&lt;/span&gt;, @description=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @facet=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Server&#039;&lt;/span&gt;, @expression=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;OpType&amp;gt;OR&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;VersionMajor&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.Double&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;10&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;VersionMajor&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.Double&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;11&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;lt;/Operator&amp;gt;&#039;&lt;/span&gt;, @is_name_condition=&lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;, @obj_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @condition_id=@condition_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @condition_id&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb95171&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Next are the policies:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb4780&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @object_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_object_set&lt;/span&gt; @object_set_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit_Policy_ObjectSet&#039;&lt;/span&gt;, @facet=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit&#039;&lt;/span&gt;, @object_set_id=@object_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @object_set_id&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @target_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_target_set&lt;/span&gt; @object_set_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit_Policy_ObjectSet&#039;&lt;/span&gt;, @type_skeleton=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Server/Audit&#039;&lt;/span&gt;, @&lt;span style=&quot;color: #0000FF;&quot;&gt;type&lt;/span&gt;=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;AUDIT&#039;&lt;/span&gt;, @enabled=&lt;span style=&quot;color: #0000FF;&quot;&gt;True&lt;/span&gt;, @target_set_id=@target_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @target_set_id&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_target_set_level&lt;/span&gt; @target_set_id=@target_set_id, @type_skeleton=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Server/Audit&#039;&lt;/span&gt;, @level_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit&#039;&lt;/span&gt;, @condition_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @target_set_level_id=&lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @policy_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_policy&lt;/span&gt; @name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit_Policy&#039;&lt;/span&gt;, @condition_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit_Condition&#039;&lt;/span&gt;, @policy_category=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @description=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @help_text=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @help_link=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @schedule_uid=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;00000000-0000-0000-0000-000000000000&#039;&lt;/span&gt;, @execution_mode=&lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;, @is_enabled=&lt;span style=&quot;color: #0000FF;&quot;&gt;False&lt;/span&gt;, @policy_id=@policy_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;, @root_condition_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ServerVersion&#039;&lt;/span&gt;, @object_set=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit_Policy_ObjectSet&#039;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @policy_id&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @object_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_object_set&lt;/span&gt; @object_set_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;DatabaseAudit_Policy_ObjectSet&#039;&lt;/span&gt;, @facet=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;DatabaseAuditSpecification&#039;&lt;/span&gt;, @object_set_id=@object_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @object_set_id&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @target_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_target_set&lt;/span&gt; @object_set_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;DatabaseAudit_Policy_ObjectSet&#039;&lt;/span&gt;, @type_skeleton=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Server/Database/DatabaseAuditSpecification&#039;&lt;/span&gt;, @&lt;span style=&quot;color: #0000FF;&quot;&gt;type&lt;/span&gt;=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;DATABASEAUDITSPECIFICATION&#039;&lt;/span&gt;, @enabled=&lt;span style=&quot;color: #0000FF;&quot;&gt;True&lt;/span&gt;, @target_set_id=@target_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @target_set_id&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_target_set_level&lt;/span&gt; @target_set_id=@target_set_id, @type_skeleton=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Server/Database/DatabaseAuditSpecification&#039;&lt;/span&gt;, @level_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;DatabaseAuditSpecification&#039;&lt;/span&gt;, @condition_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @target_set_level_id=&lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_target_set_level&lt;/span&gt; @target_set_id=@target_set_id, @type_skeleton=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Server/Database&#039;&lt;/span&gt;, @level_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Database&#039;&lt;/span&gt;, @condition_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @target_set_level_id=&lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @policy_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_policy&lt;/span&gt; @name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;DatabaseAudit_Policy&#039;&lt;/span&gt;, @condition_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;DatabaseAudit_Condition&#039;&lt;/span&gt;, @policy_category=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @description=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @help_text=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @help_link=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @schedule_uid=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;00000000-0000-0000-0000-000000000000&#039;&lt;/span&gt;, @execution_mode=&lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;, @is_enabled=&lt;span style=&quot;color: #0000FF;&quot;&gt;False&lt;/span&gt;, @policy_id=@policy_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;, @root_condition_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ServerVersion&#039;&lt;/span&gt;, @object_set=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;DatabaseAudit_Policy_ObjectSet&#039;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @policy_id&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @object_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_object_set&lt;/span&gt; @object_set_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ServerAudit_Policy_ObjectSet&#039;&lt;/span&gt;, @facet=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ServerAuditSpecification&#039;&lt;/span&gt;, @object_set_id=@object_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @object_set_id&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @target_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_target_set&lt;/span&gt; @object_set_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ServerAudit_Policy_ObjectSet&#039;&lt;/span&gt;, @type_skeleton=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Server/ServerAuditSpecification&#039;&lt;/span&gt;, @&lt;span style=&quot;color: #0000FF;&quot;&gt;type&lt;/span&gt;=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;SERVERAUDITSPECIFICATION&#039;&lt;/span&gt;, @enabled=&lt;span style=&quot;color: #0000FF;&quot;&gt;True&lt;/span&gt;, @target_set_id=@target_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @target_set_id&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_target_set_level&lt;/span&gt; @target_set_id=@target_set_id, @type_skeleton=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Server/ServerAuditSpecification&#039;&lt;/span&gt;, @level_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ServerAuditSpecification&#039;&lt;/span&gt;, @condition_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @target_set_level_id=&lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @policy_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_policy&lt;/span&gt; @name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ServerAudit_Policy&#039;&lt;/span&gt;, @condition_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ServerAudit_Condition&#039;&lt;/span&gt;, @policy_category=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @description=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @help_text=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @help_link=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @schedule_uid=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;00000000-0000-0000-0000-000000000000&#039;&lt;/span&gt;, @execution_mode=&lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;, @is_enabled=&lt;span style=&quot;color: #0000FF;&quot;&gt;False&lt;/span&gt;, @policy_id=@policy_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;, @root_condition_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ServerVersion&#039;&lt;/span&gt;, @object_set=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ServerAudit_Policy_ObjectSet&#039;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @policy_id&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb32800&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This concludes the PBM monitoring for this series. the conditions can be changed as per your needs, and the name prefixes are only suggestions that will work well with a central repository.&lt;/p&gt;

&lt;h3&gt;The Auditing Repository&lt;/h3&gt;

&lt;p&gt;So you are capturing audits to a remote server, and they are all sitting there and getting backed up occasionally. Current value of the auditing? Zero, NULL.&lt;/p&gt;

&lt;p&gt;In this form they&#039;re not providing you with any insight. Let&#039;s rather pull it into a database. First off we need one:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb46531&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;This is just a template to create a table that will host the audit information.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;Personally I would recommend to use the following format to name the table especially if it gets centralized:&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;For database audits:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;&amp;lt;DBAudit&amp;gt;_&amp;lt;Action&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;For server audits:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;&amp;lt;SQLAudit&amp;gt;_&amp;lt;Action&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;Then personally I use the following for the specifications:&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;&amp;lt;ServerAudit&amp;gt;_&amp;lt;Action&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;&amp;lt;DBAudit&amp;gt;_&amp;lt;Spec&amp;gt;_&amp;lt;Action&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;This makes it easier for naming the tables where I would take the following approach:&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;&amp;lt;SERVERNAME&amp;gt;_&amp;lt;AUDIT&amp;gt;_&amp;lt;ACTIONS&amp;gt;_&amp;lt;DATABASE_NAME&amp;gt; (OPTIONAL for database audits)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;if&lt;/span&gt; exists&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;select&lt;/span&gt; name &lt;span style=&quot;color: #0000FF;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;databases&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;where&lt;/span&gt; name = &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;[AuditingLogs]&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;drop&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;database&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;AuditingLogs&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;go&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;DATABASE&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;AuditingLogs&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;go&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;USE&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;AuditingLogs&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;TABLE&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;dbo&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;AuditTable_Template&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;event_time&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;datetime2&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NOT NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;sequence_number&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;action_id&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;succeeded&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;bit&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;permission_bitmask&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;is_column_permission&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;bit&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;session_id&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;server_principal_id&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;database_principal_id&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;target_server_principal_id&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;target_database_principal_id&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;class_type&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;session_server_principal_name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;nchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;server_principal_name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;nchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;server_principal_sid&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;varbinary&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;database_principal_name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;nchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;target_server_principal_name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;nchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;target_server_principal_sid&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;varbinary&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;target_database_principal_name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;nchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;server_instance_name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;120&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;database_name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;120&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;schema_name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;120&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_name&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;120&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;statement&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;additional_information&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;file_name&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;260&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;audit_file_offset&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;bigint&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;user_defined_event_id&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;bit&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;user_defined_information&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;nvarchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL,&lt;br /&gt;&amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;CONSTRAINT&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;PK_AuditTable_Template&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;PRIMARY&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;KEY&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;CLUSTERED&lt;/span&gt; &lt;br /&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;event_time&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;ASC&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;WITH&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;PAD_INDEX&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;OFF&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;STATISTICS_NORECOMPUTE&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;OFF&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;IGNORE_DUP_KEY&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;OFF&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;ALLOW_ROW_LOCKS&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;ALLOW_PAGE_LOCKS&lt;/span&gt; = &lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;PRIMARY&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;PRIMARY&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;SET&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;ANSI_PADDING&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;OFF&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb8994&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This gives us our database, you can just move you files to the correct directory as well as add all the secondary files and file groups you need to sustain this. There is also a table &quot;template&quot; with which to create your tables. Each table will be specific to an audit file.&lt;/p&gt;

&lt;p&gt;Next we need to get the audit information into the database, below is the script I used and can be modified to fit into either a SQL Job or SSIS package.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb92356&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;This script contains some insert statements as to how you will go about inserting your captured audit events into a SQL database.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;Note that I am using event_time as this is the most unique value that will be written down. I am also reading all the information&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;into the database as you may need this for regulatory requirements.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;USE&lt;/span&gt; AuditingLogs;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;go&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;INSERT&lt;/span&gt; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;INTO&lt;/span&gt; AuditingLogs.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Table&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; &amp;nbsp;*&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;fn_get_audit_file&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;file&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;*.sqlaudit&#039;&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; gaf&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; &amp;nbsp; gaf.&lt;span style=&quot;color: #202020;&quot;&gt;event_time&lt;/span&gt; NOT IN &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; &amp;nbsp;event_time&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;table&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;INSERT&lt;/span&gt; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;INTO&lt;/span&gt; AuditingLogs.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Table&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; &amp;nbsp;*&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;fn_get_audit_file&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;file*.sqlaudit&#039;&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; gaf&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; &amp;nbsp; gaf.&lt;span style=&quot;color: #202020;&quot;&gt;event_time&lt;/span&gt; NOT IN &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; &amp;nbsp;event_time&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;table&lt;/span&gt; &amp;nbsp;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;INSERT&lt;/span&gt; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;INTO&lt;/span&gt; AuditingLogs.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Table&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; &amp;nbsp;*&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;fn_get_audit_file&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;file*.sqlaudit&#039;&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; gaf&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; &amp;nbsp; gaf.&lt;span style=&quot;color: #202020;&quot;&gt;event_time&lt;/span&gt; NOT IN &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; &amp;nbsp;event_time&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;table&lt;/span&gt; &amp;nbsp;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb54082&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is currently very basic, and I included some comments into the scripts to give you an overview of what is going on.&lt;/p&gt;

&lt;p&gt;For one of the audits used in demoing the SQL Server Auditing feature, I pulled all the information into a table. As per the sys.fn_get_audit_file we can return the same results from the table. In the following example I&#039;m using sys.dm_audit_actions to join to the table to make the information more clear:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb22723&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;USE&lt;/span&gt; AuditingLogs ;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;go&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; &amp;nbsp;del.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;event_time&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; aa.&lt;span style=&quot;color: #202020;&quot;&gt;name&lt;/span&gt; ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; aa.&lt;span style=&quot;color: #202020;&quot;&gt;action_in_log&lt;/span&gt; ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; del.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;session_id&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; del.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;session_server_principal_name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; del.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;server_instance_name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; del.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;database_name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; del.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_name&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; del.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;statement&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;dbo&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;SQL2012_DBAudit_Deletes&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; del&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; JOIN &lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;dm_audit_actions&lt;/span&gt; aa &lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt; aa.&lt;span style=&quot;color: #202020;&quot;&gt;action_id&lt;/span&gt; = del.&lt;span style=&quot;color: #202020;&quot;&gt;action_id&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ORDER&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;BY&lt;/span&gt; del.&lt;span style=&quot;color: #202020;&quot;&gt;event_time&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;ASC&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb37353&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is the result:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/query_exmaple_results.jpg?mtime=1326109318&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/query_exmaple_results.jpg?mtime=1326109318&quot; width=&quot;1077&quot; height=&quot;114&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;Currently the database is only hosting the information and it will be nice if Microsoft will add the ability to audit directly to a table in future versions of SQL Server.&lt;/p&gt;

&lt;h3&gt;Closing the Chapter&lt;/h3&gt;

&lt;p&gt;The auditing feature very useful, and is significantly more so than C2 auditing due to the level of granularity. This is also one of the drawbacks; if the auditing is not well planned out it can bring your database or even server to its knees. As with all auditing mechanisms this feature can chew it&#039;s way through SAN and a lot of thought needs to go into planning this, and if done so, will pay off greatly in the end. With filtering included in SQL Server 2012 it relieves some of this drawbacks in terms of the impact across a SQL Server instance. Overall I think it&#039;s a great feature, and it still has the ability to improve greatly.&lt;/p&gt;

&lt;p&gt;Below are the links to the rest of the series:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/?p=1557&quot;&gt;SQL Server Auditing: Introduction&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/?p=1558&quot;&gt;SQL Server Auditing: Creating a Server Specification&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/?p=1568&quot;&gt;SQL Server Auditing: Creating a Database Specification&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/?p=1573&quot;&gt;SQL Server Auditing: Managing Your Audits&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;&lt;em&gt;Note. Keep an eye on LessThanDot.com to see some cool things happen to the audit repository!!!&lt;/em&gt;&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-looking-back&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Over the past couple of weeks, we have looked at the new auditing feature introduced in SQL Server 2008. This post will finish up with the series and will cover the remaining subjects:<br />
 <br />
1.SQL Server 2008 vs. SQL Server 2012,<br />
2.PBM - Last take on auditing your audits,<br />
3.The Auditing Repository.</p>


<h3>SQL Server 2008 vs. SQL Server 2012</h3>

<p>The new release of SQL Server is around the corner, and with it there are numerous enhancements to the various components as well as new features. The auditing component is no different. There are a total of 507 audit actions in SQL Server 2012 compared to the 454 in SQL Server 2008 R2. Some of the new actions are more specifically geared to the new SQL Server 2012 Database Containment Feature.</p>

<p>In addition to this, it also introduces filtering to your audits. This is set up on your audit instead of the Server Audit Specification or Database Audit Specification. This will limited what is written to the audit file even more, however there will be the additional CPU overhead to pay for filtering the audits.</p>

<p>Let's take a look how to set it up through the SSMS:</p>

<p>First of all, create the audit as previously and navigate as in the screenshot. Note that we will use testdb, check for dbo schema and only actions taking place by users which are defined as a DB_Owner:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/SQL2012_New/Filtered_Audit_GUI.jpg?mtime=1326103445"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/SQL2012_New/Filtered_Audit_GUI.jpg?mtime=1326103445" width="602" height="170" /></a></div>

<p>Next we define a Server Audit Specification to Capture Schema access:<br />
<em>Note. This is necessary to capture the events. Previously a Server Audit Specification captured ALL the events across ALL databases.</em></p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/SQL2012_New/Filtered_Audit_Spec_GUI.jpg?mtime=1326103453"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/SQL2012_New/Filtered_Audit_Spec_GUI.jpg?mtime=1326103453" width="457" height="135" /></a></div>

<p>To create the same audit using TSQL(which is easier) is as follows:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb19828'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb19828','cb12914'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb19828" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">USE</span> <span style="color: #808080;">&#91;</span>master<span style="color: #808080;">&#93;</span></li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">CREATE</span> SERVER <span style="color: #0000FF;">AUDIT</span> <span style="color: #808080;">&#91;</span>Filtered<span style="color: #808080;">&#93;</span></li><li style="" class="li1"><span style="color: #0000FF;">TO</span> <span style="color: #0000FF;">FILE</span> </li><li style="" class="li2"><span style="color: #808080;">&#40;</span>&nbsp; &nbsp;<span style="color: #0000FF;">FILEPATH</span> = N<span style="color: #FF0000;">'E:\SQLAuditing\'</span></li><li style="" class="li1">&nbsp; &nbsp; ,<span style="color: #0000FF;">MAXSIZE</span> = <span style="color: #000;">10</span> <span style="color: #0000FF;">MB</span></li><li style="" class="li2">&nbsp; &nbsp; ,<span style="color: #0000FF;">MAX_FILES</span> = <span style="color: #000;">1</span></li><li style="" class="li1">&nbsp; &nbsp; ,<span style="color: #0000FF;">RESERVE_DISK_SPACE</span> = <span style="color: #0000FF;">OFF</span></li><li style="" class="li2"><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">WITH</span></li><li style="" class="li2"><span style="color: #808080;">&#40;</span>&nbsp; &nbsp;<span style="color: #0000FF;">QUEUE_DELAY</span> = <span style="color: #000;">1000</span></li><li style="" class="li1">&nbsp; &nbsp; ,<span style="color: #0000FF;">ON_FAILURE</span> = <span style="color: #0000FF;">CONTINUE</span></li><li style="" class="li2">&nbsp; &nbsp; </li><li style="" class="li1"><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">WHERE</span> <span style="color: #808080;">&#40;</span><span style="color: #808080;">&#91;</span>database_name<span style="color: #808080;">&#93;</span>=<span style="color: #FF0000;">'testdb'</span> AND <span style="color: #808080;">&#91;</span>schema_name<span style="color: #808080;">&#93;</span>=<span style="color: #FF0000;">'dbo'</span> AND <span style="color: #808080;">&#91;</span><span style="color: #FF00FF;">object_name</span><span style="color: #808080;">&#93;</span>=<span style="color: #FF0000;">'tab1'</span> AND <span style="color: #808080;">&#91;</span>database_principal_name<span style="color: #808080;">&#93;</span>=<span style="color: #FF0000;">'dbo'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">ALTER</span> SERVER <span style="color: #0000FF;">AUDIT</span> <span style="color: #808080;">&#91;</span>Filtered<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">WITH</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">STATE</span> = <span style="color: #0000FF;">ON</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">USE</span> <span style="color: #808080;">&#91;</span>master<span style="color: #808080;">&#93;</span></li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">CREATE</span> SERVER <span style="color: #0000FF;">AUDIT</span> <span style="color: #0000FF;">SPECIFICATION</span> <span style="color: #808080;">&#91;</span>Server_Spec_Filtering<span style="color: #808080;">&#93;</span></li><li style="" class="li2"><span style="color: #0000FF;">FOR</span> SERVER <span style="color: #0000FF;">AUDIT</span> <span style="color: #808080;">&#91;</span>Filtered<span style="color: #808080;">&#93;</span></li><li style="" class="li1"><span style="color: #0000FF;">ADD</span> <span style="color: #808080;">&#40;</span>SCHEMA_OBJECT_ACCESS_GROUP<span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">WITH</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">STATE</span> = <span style="color: #0000FF;">OFF</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li></ol></div><div id="cb12914" style="display: none; color: red;"></div></div></div>

<p>Below is the results of querying an audit file with the filter:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/SQL2012_New/Filtered_Results.jpg?mtime=1326103463"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/SQL2012_New/Filtered_Results.jpg?mtime=1326103463" width="732" height="63" /></a></div>

<p>Other additional functionality is OnError:Fail Operation as well as maximum number of files. Maximum number of files indicates the number of files needed to be kept.</p>


<h3>PBM - Last Take On Auditing Your Audits</h3>

<p>Continuing from the last post, below is some policies which you can use with SQL Server 2008/R2/2012.</p>

<p>They are as follows:<br />
1. Audit files.<br />
2. Database Audits.<br />
3. Server Audits.</p>

<p><em>Note. I included a ServerVersion condition if you intend to use this with the Enterprise Policy Framework. This will only execute the policies against SQL Server 2008 upwards.</em></p>

<p>These policies will take a look at the naming convention for the policies as follows:</p>

<p>Database Audits:</p>

<p>1. Name starts with 'DBAudit_%.<br />
2. Audit file name starts with 'DBAudit_Spec_%'.<br />
3. Audit is enabled.</p>

<p>Server Audits:</p>

<p>1. Name starts with 'SQLAudit_%'.<br />
2. Audit file name starts with 'ServerAudit_%'.<br />
3. Audit is enabled.</p>

<p>Audit Files:</p>

<p>1. Audit file is enabled.<br />
2. Destination type is file.<br />
3. 100 Maximum files.<br />
4. 10 Roll over files<br />
5. File size is maximum 5GB.<br />
6. File size unit is GB.<br />
7. Reserve disk space true.</p>

<p>Below are the create conditions:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb55032'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb55032','cb25958'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb55032" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #00AF00;">--- Audit_Condition</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">Declare</span> @condition_id <span style="color: #0000FF;">int</span></li><li style="" class="li2"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_condition</span> @name=N<span style="color: #FF0000;">'Audit_Condition'</span>, @description=N<span style="color: #FF0000;">''</span>, @facet=N<span style="color: #FF0000;">'Audit'</span>, @expression=N<span style="color: #FF0000;">'&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;OpType&gt;AND&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;OpType&gt;AND&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;OpType&gt;AND&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;OpType&gt;AND&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;OpType&gt;AND&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;OpType&gt;AND&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Name&gt;Enabled&lt;/Name&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Function&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;FunctionType&gt;True&lt;/FunctionType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ReturnType&gt;Bool&lt;/ReturnType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;0&lt;/Count&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Function&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Name&gt;DestinationType&lt;/Name&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Function&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;FunctionType&gt;Enum&lt;/FunctionType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ReturnType&gt;Numeric&lt;/ReturnType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.String&lt;/ObjType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;Microsoft.SqlServer.Management.Smo.AuditDestinationType&lt;/Value&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.String&lt;/ObjType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;File&lt;/Value&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Function&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Name&gt;MaximumFiles&lt;/Name&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.Double&lt;/ObjType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;100&lt;/Value&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Name&gt;MaximumRolloverFiles&lt;/Name&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.Double&lt;/ObjType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;10&lt;/Value&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Name&gt;MaximumFileSize&lt;/Name&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.Double&lt;/ObjType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;5&lt;/Value&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Name&gt;MaximumFileSizeUnit&lt;/Name&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Function&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;FunctionType&gt;Enum&lt;/FunctionType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;ReturnType&gt;Numeric&lt;/ReturnType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.String&lt;/ObjType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;Microsoft.SqlServer.Management.Smo.AuditFileSizeUnit&lt;/Value&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.String&lt;/ObjType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;Gb&lt;/Value&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Function&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Name&gt;ReserveDiskSpace&lt;/Name&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Function&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;FunctionType&gt;True&lt;/FunctionType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;ReturnType&gt;Bool&lt;/ReturnType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Count&gt;0&lt;/Count&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Function&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;">&lt;/Operator&gt;'</span>, @is_name_condition=<span style="color: #000;">0</span>, @obj_name=N<span style="color: #FF0000;">''</span>, @condition_id=@condition_id <span style="color: #0000FF;">OUTPUT</span></li><li style="" class="li2"><span style="color: #0000FF;">Select</span> @condition_id</li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #00AF00;">--- DatabaseAudit_Condition</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">Declare</span> @condition_id <span style="color: #0000FF;">int</span></li><li style="" class="li2"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_condition</span> @name=N<span style="color: #FF0000;">'DatabaseAudit_Condition'</span>, @description=N<span style="color: #FF0000;">''</span>, @facet=N<span style="color: #FF0000;">'DatabaseAuditSpecification'</span>, @expression=N<span style="color: #FF0000;">'&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;OpType&gt;AND&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;OpType&gt;AND&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;OpType&gt;LIKE&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Name&gt;AuditName&lt;/Name&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.String&lt;/ObjType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;DBAudit_%&lt;/Value&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;OpType&gt;LIKE&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Name&gt;Name&lt;/Name&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.String&lt;/ObjType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;DBAudit_Spec_%&lt;/Value&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Name&gt;Enabled&lt;/Name&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Function&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;FunctionType&gt;True&lt;/FunctionType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;ReturnType&gt;Bool&lt;/ReturnType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Count&gt;0&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Function&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;">&lt;/Operator&gt;'</span>, @is_name_condition=<span style="color: #000;">0</span>, @obj_name=N<span style="color: #FF0000;">''</span>, @condition_id=@condition_id <span style="color: #0000FF;">OUTPUT</span></li><li style="" class="li1"><span style="color: #0000FF;">Select</span> @condition_id</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #00AF00;">--- ServerAudit_Condition</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">Declare</span> @condition_id <span style="color: #0000FF;">int</span></li><li style="" class="li2"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_condition</span> @name=N<span style="color: #FF0000;">'ServerAudit_Condition'</span>, @description=N<span style="color: #FF0000;">''</span>, @facet=N<span style="color: #FF0000;">'ServerAuditSpecification'</span>, @expression=N<span style="color: #FF0000;">'&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;OpType&gt;AND&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;OpType&gt;AND&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;OpType&gt;LIKE&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Name&gt;AuditName&lt;/Name&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.String&lt;/ObjType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;SQLAudit_%&lt;/Value&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;OpType&gt;LIKE&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Name&gt;Name&lt;/Name&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.String&lt;/ObjType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;ServerAudit_%&lt;/Value&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Name&gt;Enabled&lt;/Name&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Function&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;FunctionType&gt;True&lt;/FunctionType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;ReturnType&gt;Bool&lt;/ReturnType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Count&gt;0&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Function&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;">&lt;/Operator&gt;'</span>, @is_name_condition=<span style="color: #000;">0</span>, @obj_name=N<span style="color: #FF0000;">''</span>, @condition_id=@condition_id <span style="color: #0000FF;">OUTPUT</span></li><li style="" class="li1"><span style="color: #0000FF;">Select</span> @condition_id</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #00AF00;">---ServerVersion</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">Declare</span> @condition_id <span style="color: #0000FF;">int</span></li><li style="" class="li1"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_condition</span> @name=N<span style="color: #FF0000;">'ServerVersion'</span>, @description=N<span style="color: #FF0000;">''</span>, @facet=N<span style="color: #FF0000;">'Server'</span>, @expression=N<span style="color: #FF0000;">'&lt;Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;OpType&gt;OR&lt;/OpType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Name&gt;VersionMajor&lt;/Name&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.Double&lt;/ObjType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Value&gt;10&lt;/Value&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Name&gt;VersionMajor&lt;/Name&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.Double&lt;/ObjType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Value&gt;11&lt;/Value&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;">&lt;/Operator&gt;'</span>, @is_name_condition=<span style="color: #000;">0</span>, @obj_name=N<span style="color: #FF0000;">''</span>, @condition_id=@condition_id <span style="color: #0000FF;">OUTPUT</span></li><li style="" class="li2"><span style="color: #0000FF;">Select</span> @condition_id</li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li></ol></div><div id="cb25958" style="display: none; color: red;"></div></div></div>

<p>Next are the policies:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb46883'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb46883','cb764'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb46883" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">Declare</span> @object_set_id <span style="color: #0000FF;">int</span></li><li style="" class="li2"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_object_set</span> @object_set_name=N<span style="color: #FF0000;">'Audit_Policy_ObjectSet'</span>, @facet=N<span style="color: #FF0000;">'Audit'</span>, @object_set_id=@object_set_id <span style="color: #0000FF;">OUTPUT</span></li><li style="" class="li1"><span style="color: #0000FF;">Select</span> @object_set_id</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">Declare</span> @target_set_id <span style="color: #0000FF;">int</span></li><li style="" class="li2"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_target_set</span> @object_set_name=N<span style="color: #FF0000;">'Audit_Policy_ObjectSet'</span>, @type_skeleton=N<span style="color: #FF0000;">'Server/Audit'</span>, @<span style="color: #0000FF;">type</span>=N<span style="color: #FF0000;">'AUDIT'</span>, @enabled=<span style="color: #0000FF;">True</span>, @target_set_id=@target_set_id <span style="color: #0000FF;">OUTPUT</span></li><li style="" class="li1"><span style="color: #0000FF;">Select</span> @target_set_id</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_target_set_level</span> @target_set_id=@target_set_id, @type_skeleton=N<span style="color: #FF0000;">'Server/Audit'</span>, @level_name=N<span style="color: #FF0000;">'Audit'</span>, @condition_name=N<span style="color: #FF0000;">''</span>, @target_set_level_id=<span style="color: #000;">0</span></li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">Declare</span> @policy_id <span style="color: #0000FF;">int</span></li><li style="" class="li1"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_policy</span> @name=N<span style="color: #FF0000;">'Audit_Policy'</span>, @condition_name=N<span style="color: #FF0000;">'Audit_Condition'</span>, @policy_category=N<span style="color: #FF0000;">''</span>, @description=N<span style="color: #FF0000;">''</span>, @help_text=N<span style="color: #FF0000;">''</span>, @help_link=N<span style="color: #FF0000;">''</span>, @schedule_uid=N<span style="color: #FF0000;">'00000000-0000-0000-0000-000000000000'</span>, @execution_mode=<span style="color: #000;">0</span>, @is_enabled=<span style="color: #0000FF;">False</span>, @policy_id=@policy_id <span style="color: #0000FF;">OUTPUT</span>, @root_condition_name=N<span style="color: #FF0000;">'ServerVersion'</span>, @object_set=N<span style="color: #FF0000;">'Audit_Policy_ObjectSet'</span></li><li style="" class="li2"><span style="color: #0000FF;">Select</span> @policy_id</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">Declare</span> @object_set_id <span style="color: #0000FF;">int</span></li><li style="" class="li2"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_object_set</span> @object_set_name=N<span style="color: #FF0000;">'DatabaseAudit_Policy_ObjectSet'</span>, @facet=N<span style="color: #FF0000;">'DatabaseAuditSpecification'</span>, @object_set_id=@object_set_id <span style="color: #0000FF;">OUTPUT</span></li><li style="" class="li1"><span style="color: #0000FF;">Select</span> @object_set_id</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">Declare</span> @target_set_id <span style="color: #0000FF;">int</span></li><li style="" class="li2"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_target_set</span> @object_set_name=N<span style="color: #FF0000;">'DatabaseAudit_Policy_ObjectSet'</span>, @type_skeleton=N<span style="color: #FF0000;">'Server/Database/DatabaseAuditSpecification'</span>, @<span style="color: #0000FF;">type</span>=N<span style="color: #FF0000;">'DATABASEAUDITSPECIFICATION'</span>, @enabled=<span style="color: #0000FF;">True</span>, @target_set_id=@target_set_id <span style="color: #0000FF;">OUTPUT</span></li><li style="" class="li1"><span style="color: #0000FF;">Select</span> @target_set_id</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_target_set_level</span> @target_set_id=@target_set_id, @type_skeleton=N<span style="color: #FF0000;">'Server/Database/DatabaseAuditSpecification'</span>, @level_name=N<span style="color: #FF0000;">'DatabaseAuditSpecification'</span>, @condition_name=N<span style="color: #FF0000;">''</span>, @target_set_level_id=<span style="color: #000;">0</span></li><li style="" class="li2"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_target_set_level</span> @target_set_id=@target_set_id, @type_skeleton=N<span style="color: #FF0000;">'Server/Database'</span>, @level_name=N<span style="color: #FF0000;">'Database'</span>, @condition_name=N<span style="color: #FF0000;">''</span>, @target_set_level_id=<span style="color: #000;">0</span></li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">Declare</span> @policy_id <span style="color: #0000FF;">int</span></li><li style="" class="li2"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_policy</span> @name=N<span style="color: #FF0000;">'DatabaseAudit_Policy'</span>, @condition_name=N<span style="color: #FF0000;">'DatabaseAudit_Condition'</span>, @policy_category=N<span style="color: #FF0000;">''</span>, @description=N<span style="color: #FF0000;">''</span>, @help_text=N<span style="color: #FF0000;">''</span>, @help_link=N<span style="color: #FF0000;">''</span>, @schedule_uid=N<span style="color: #FF0000;">'00000000-0000-0000-0000-000000000000'</span>, @execution_mode=<span style="color: #000;">0</span>, @is_enabled=<span style="color: #0000FF;">False</span>, @policy_id=@policy_id <span style="color: #0000FF;">OUTPUT</span>, @root_condition_name=N<span style="color: #FF0000;">'ServerVersion'</span>, @object_set=N<span style="color: #FF0000;">'DatabaseAudit_Policy_ObjectSet'</span></li><li style="" class="li1"><span style="color: #0000FF;">Select</span> @policy_id</li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">Declare</span> @object_set_id <span style="color: #0000FF;">int</span></li><li style="" class="li1"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_object_set</span> @object_set_name=N<span style="color: #FF0000;">'ServerAudit_Policy_ObjectSet'</span>, @facet=N<span style="color: #FF0000;">'ServerAuditSpecification'</span>, @object_set_id=@object_set_id <span style="color: #0000FF;">OUTPUT</span></li><li style="" class="li2"><span style="color: #0000FF;">Select</span> @object_set_id</li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">Declare</span> @target_set_id <span style="color: #0000FF;">int</span></li><li style="" class="li1"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_target_set</span> @object_set_name=N<span style="color: #FF0000;">'ServerAudit_Policy_ObjectSet'</span>, @type_skeleton=N<span style="color: #FF0000;">'Server/ServerAuditSpecification'</span>, @<span style="color: #0000FF;">type</span>=N<span style="color: #FF0000;">'SERVERAUDITSPECIFICATION'</span>, @enabled=<span style="color: #0000FF;">True</span>, @target_set_id=@target_set_id <span style="color: #0000FF;">OUTPUT</span></li><li style="" class="li2"><span style="color: #0000FF;">Select</span> @target_set_id</li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_target_set_level</span> @target_set_id=@target_set_id, @type_skeleton=N<span style="color: #FF0000;">'Server/ServerAuditSpecification'</span>, @level_name=N<span style="color: #FF0000;">'ServerAuditSpecification'</span>, @condition_name=N<span style="color: #FF0000;">''</span>, @target_set_level_id=<span style="color: #000;">0</span></li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">Declare</span> @policy_id <span style="color: #0000FF;">int</span></li><li style="" class="li2"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_policy</span> @name=N<span style="color: #FF0000;">'ServerAudit_Policy'</span>, @condition_name=N<span style="color: #FF0000;">'ServerAudit_Condition'</span>, @policy_category=N<span style="color: #FF0000;">''</span>, @description=N<span style="color: #FF0000;">''</span>, @help_text=N<span style="color: #FF0000;">''</span>, @help_link=N<span style="color: #FF0000;">''</span>, @schedule_uid=N<span style="color: #FF0000;">'00000000-0000-0000-0000-000000000000'</span>, @execution_mode=<span style="color: #000;">0</span>, @is_enabled=<span style="color: #0000FF;">False</span>, @policy_id=@policy_id <span style="color: #0000FF;">OUTPUT</span>, @root_condition_name=N<span style="color: #FF0000;">'ServerVersion'</span>, @object_set=N<span style="color: #FF0000;">'ServerAudit_Policy_ObjectSet'</span></li><li style="" class="li1"><span style="color: #0000FF;">Select</span> @policy_id</li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li></ol></div><div id="cb764" style="display: none; color: red;"></div></div></div>

<p>This concludes the PBM monitoring for this series. the conditions can be changed as per your needs, and the name prefixes are only suggestions that will work well with a central repository.</p>

<h3>The Auditing Repository</h3>

<p>So you are capturing audits to a remote server, and they are all sitting there and getting backed up occasionally. Current value of the auditing? Zero, NULL.</p>

<p>In this form they're not providing you with any insight. Let's rather pull it into a database. First off we need one:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb5263'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb5263','cb70413'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb5263" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #00AF00;">/*</span></li><li style="" class="li2"><span style="color: #00AF00;">This is just a template to create a table that will host the audit information.</span></li><li style="" class="li1"><span style="color: #00AF00;">Personally I would recommend to use the following format to name the table especially if it gets centralized:</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #00AF00;">For database audits:</span></li><li style="" class="li2"><span style="color: #00AF00;">&lt;DBAudit&gt;_&lt;Action&gt;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #00AF00;">For server audits:</span></li><li style="" class="li1"><span style="color: #00AF00;">&lt;SQLAudit&gt;_&lt;Action&gt;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #00AF00;">Then personally I use the following for the specifications:</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #00AF00;">&lt;ServerAudit&gt;_&lt;Action&gt;</span></li><li style="" class="li2"><span style="color: #00AF00;">&lt;DBAudit&gt;_&lt;Spec&gt;_&lt;Action&gt;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #00AF00;">This makes it easier for naming the tables where I would take the following approach:</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #00AF00;">&lt;SERVERNAME&gt;_&lt;AUDIT&gt;_&lt;ACTIONS&gt;_&lt;DATABASE_NAME&gt; (OPTIONAL for database audits)</span></li><li style="" class="li1"><span style="color: #00AF00;">*/</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">if</span> exists<span style="color: #808080;">&#40;</span><span style="color: #0000FF;">select</span> name <span style="color: #0000FF;">from</span> <span style="color: #00AF00;">sys</span>.<span style="color: #202020;">databases</span> <span style="color: #0000FF;">where</span> name = <span style="color: #FF0000;">'[AuditingLogs]'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">drop</span> <span style="color: #0000FF;">database</span> <span style="color: #808080;">&#91;</span>AuditingLogs<span style="color: #808080;">&#93;</span>;</li><li style="" class="li1"><span style="color: #0000FF;">go</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">DATABASE</span> <span style="color: #808080;">&#91;</span>AuditingLogs<span style="color: #808080;">&#93;</span>;</li><li style="" class="li2"><span style="color: #0000FF;">go</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">USE</span> <span style="color: #808080;">&#91;</span>AuditingLogs<span style="color: #808080;">&#93;</span>;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span>;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>AuditTable_Template<span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>event_time<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">datetime2</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">7</span><span style="color: #808080;">&#41;</span> NOT NULL,</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>sequence_number<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">int</span><span style="color: #808080;">&#93;</span> NULL,</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>action_id<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">char</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">4</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>succeeded<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">bit</span><span style="color: #808080;">&#93;</span> NULL,</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>permission_bitmask<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">bigint</span><span style="color: #808080;">&#93;</span> NULL,</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>is_column_permission<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">bit</span><span style="color: #808080;">&#93;</span> NULL,</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>session_id<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">int</span><span style="color: #808080;">&#93;</span> NULL,</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>server_principal_id<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">int</span><span style="color: #808080;">&#93;</span> NULL,</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>database_principal_id<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">int</span><span style="color: #808080;">&#93;</span> NULL,</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>target_server_principal_id<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">int</span><span style="color: #808080;">&#93;</span> NULL,</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>target_database_principal_id<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">int</span><span style="color: #808080;">&#93;</span> NULL,</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span><span style="color: #FF00FF;">object_id</span><span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">int</span><span style="color: #808080;">&#93;</span> NULL,</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>class_type<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">char</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>session_server_principal_name<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">nchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">30</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>server_principal_name<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">nchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">30</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>server_principal_sid<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">varbinary</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">50</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>database_principal_name<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">nchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">30</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>target_server_principal_name<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">nchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">30</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>target_server_principal_sid<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">varbinary</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">50</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>target_database_principal_name<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">nchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">30</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>server_instance_name<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">nvarchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">120</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>database_name<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">nvarchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">120</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>schema_name<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">nvarchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">120</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span><span style="color: #FF00FF;">object_name</span><span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">nvarchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">120</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">statement</span><span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">nvarchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">4000</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>additional_information<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">nvarchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">4000</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span><span style="color: #FF00FF;">file_name</span><span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">260</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>audit_file_offset<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">bigint</span><span style="color: #808080;">&#93;</span> NULL,</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>user_defined_event_id<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">bit</span><span style="color: #808080;">&#93;</span> NULL,</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>user_defined_information<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">nvarchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">4000</span><span style="color: #808080;">&#41;</span> NULL,</li><li style="" class="li2">&nbsp;<span style="color: #0000FF;">CONSTRAINT</span> <span style="color: #808080;">&#91;</span>PK_AuditTable_Template<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">PRIMARY</span> <span style="color: #0000FF;">KEY</span> <span style="color: #0000FF;">CLUSTERED</span> </li><li style="" class="li1"><span style="color: #808080;">&#40;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#91;</span>event_time<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">ASC</span></li><li style="" class="li1"><span style="color: #808080;">&#41;</span><span style="color: #0000FF;">WITH</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">PAD_INDEX</span> = <span style="color: #0000FF;">OFF</span>, <span style="color: #0000FF;">STATISTICS_NORECOMPUTE</span> = <span style="color: #0000FF;">OFF</span>, <span style="color: #0000FF;">IGNORE_DUP_KEY</span> = <span style="color: #0000FF;">OFF</span>, <span style="color: #0000FF;">ALLOW_ROW_LOCKS</span> = <span style="color: #0000FF;">ON</span>, <span style="color: #0000FF;">ALLOW_PAGE_LOCKS</span> = <span style="color: #0000FF;">ON</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">ON</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">PRIMARY</span><span style="color: #808080;">&#93;</span></li><li style="" class="li2"><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">ON</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">PRIMARY</span><span style="color: #808080;">&#93;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1"><span style="color: #0000FF;">SET</span> <span style="color: #0000FF;">ANSI_PADDING</span> <span style="color: #0000FF;">OFF</span></li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li></ol></div><div id="cb70413" style="display: none; color: red;"></div></div></div>

<p>This gives us our database, you can just move you files to the correct directory as well as add all the secondary files and file groups you need to sustain this. There is also a table "template" with which to create your tables. Each table will be specific to an audit file.</p>

<p>Next we need to get the audit information into the database, below is the script I used and can be modified to fit into either a SQL Job or SSIS package.</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb1443'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb1443','cb36532'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb1443" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #00AF00;">/*</span></li><li style="" class="li2"><span style="color: #00AF00;">This script contains some insert statements as to how you will go about inserting your captured audit events into a SQL database.</span></li><li style="" class="li1"><span style="color: #00AF00;">Note that I am using event_time as this is the most unique value that will be written down. I am also reading all the information</span></li><li style="" class="li2"><span style="color: #00AF00;">into the database as you may need this for regulatory requirements.</span></li><li style="" class="li1"><span style="color: #00AF00;">*/</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">USE</span> AuditingLogs;</li><li style="" class="li2"><span style="color: #0000FF;">go</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">INSERT</span> &nbsp;<span style="color: #0000FF;">INTO</span> AuditingLogs.<span style="color: #202020;">dbo</span>.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">Table</span><span style="color: #808080;">&#93;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">SELECT</span> &nbsp;*</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">FROM</span> &nbsp; &nbsp;<span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">fn_get_audit_file</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">file</span><span style="color: #FF0000;">'*.sqlaudit'</span>,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">DEFAULT</span>, <span style="color: #0000FF;">DEFAULT</span><span style="color: #808080;">&#41;</span> gaf</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">WHERE</span> &nbsp; gaf.<span style="color: #202020;">event_time</span> NOT IN <span style="color: #808080;">&#40;</span> <span style="color: #0000FF;">SELECT</span> &nbsp;event_time</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">FROM</span> &nbsp; &nbsp;<span style="color: #0000FF;">table</span> <span style="color: #808080;">&#41;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">INSERT</span> &nbsp;<span style="color: #0000FF;">INTO</span> AuditingLogs.<span style="color: #202020;">dbo</span>.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">Table</span><span style="color: #808080;">&#93;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">SELECT</span> &nbsp;*</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">FROM</span> &nbsp; &nbsp;<span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">fn_get_audit_file</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'file*.sqlaudit'</span>,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">DEFAULT</span>, <span style="color: #0000FF;">DEFAULT</span><span style="color: #808080;">&#41;</span> gaf</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">WHERE</span> &nbsp; gaf.<span style="color: #202020;">event_time</span> NOT IN <span style="color: #808080;">&#40;</span> <span style="color: #0000FF;">SELECT</span> &nbsp;event_time</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">FROM</span> &nbsp; &nbsp;<span style="color: #0000FF;">table</span> &nbsp;<span style="color: #808080;">&#41;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">INSERT</span> &nbsp;<span style="color: #0000FF;">INTO</span> AuditingLogs.<span style="color: #202020;">dbo</span>.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">Table</span><span style="color: #808080;">&#93;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">SELECT</span> &nbsp;*</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">FROM</span> &nbsp; &nbsp;<span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">fn_get_audit_file</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'file*.sqlaudit'</span>,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">DEFAULT</span>, <span style="color: #0000FF;">DEFAULT</span><span style="color: #808080;">&#41;</span> gaf</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">WHERE</span> &nbsp; gaf.<span style="color: #202020;">event_time</span> NOT IN <span style="color: #808080;">&#40;</span> <span style="color: #0000FF;">SELECT</span> &nbsp;event_time</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">FROM</span> &nbsp; &nbsp;<span style="color: #0000FF;">table</span> &nbsp;<span style="color: #808080;">&#41;</span></li></ol></div><div id="cb36532" style="display: none; color: red;"></div></div></div>

<p>This is currently very basic, and I included some comments into the scripts to give you an overview of what is going on.</p>

<p>For one of the audits used in demoing the SQL Server Auditing feature, I pulled all the information into a table. As per the sys.fn_get_audit_file we can return the same results from the table. In the following example I'm using sys.dm_audit_actions to join to the table to make the information more clear:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb86487'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb86487','cb58506'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb86487" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">USE</span> AuditingLogs ;</li><li style="" class="li2"><span style="color: #0000FF;">go</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">SELECT</span> &nbsp;del.<span style="color: #808080;">&#91;</span>event_time<span style="color: #808080;">&#93;</span> ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; aa.<span style="color: #202020;">name</span> ,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; aa.<span style="color: #202020;">action_in_log</span> ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; del.<span style="color: #808080;">&#91;</span>session_id<span style="color: #808080;">&#93;</span> ,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; del.<span style="color: #808080;">&#91;</span>session_server_principal_name<span style="color: #808080;">&#93;</span> ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; del.<span style="color: #808080;">&#91;</span>server_instance_name<span style="color: #808080;">&#93;</span> ,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; del.<span style="color: #808080;">&#91;</span>database_name<span style="color: #808080;">&#93;</span> ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; del.<span style="color: #808080;">&#91;</span><span style="color: #FF00FF;">object_name</span><span style="color: #808080;">&#93;</span> ,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; del.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">statement</span><span style="color: #808080;">&#93;</span></li><li style="" class="li1"><span style="color: #0000FF;">FROM</span> &nbsp; &nbsp;<span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>SQL2012_DBAudit_Deletes<span style="color: #808080;">&#93;</span> del</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; JOIN <span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">dm_audit_actions</span> aa <span style="color: #0000FF;">ON</span> aa.<span style="color: #202020;">action_id</span> = del.<span style="color: #202020;">action_id</span></li><li style="" class="li1"><span style="color: #0000FF;">ORDER</span> <span style="color: #0000FF;">BY</span> del.<span style="color: #202020;">event_time</span> <span style="color: #0000FF;">ASC</span></li></ol></div><div id="cb58506" style="display: none; color: red;"></div></div></div>

<p>This is the result:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/query_exmaple_results.jpg?mtime=1326109318"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/LookingBack/query_exmaple_results.jpg?mtime=1326109318" width="1077" height="114" /></a></div>

<p>Currently the database is only hosting the information and it will be nice if Microsoft will add the ability to audit directly to a table in future versions of SQL Server.</p>

<h3>Closing the Chapter</h3>

<p>The auditing feature very useful, and is significantly more so than C2 auditing due to the level of granularity. This is also one of the drawbacks; if the auditing is not well planned out it can bring your database or even server to its knees. As with all auditing mechanisms this feature can chew it's way through SAN and a lot of thought needs to go into planning this, and if done so, will pay off greatly in the end. With filtering included in SQL Server 2012 it relieves some of this drawbacks in terms of the impact across a SQL Server instance. Overall I think it's a great feature, and it still has the ability to improve greatly.</p>

<p>Below are the links to the rest of the series:</p>

<p><a href="http://blogs.lessthandot.com/index.php/DataMgmt/?p=1557">SQL Server Auditing: Introduction</a><br />
<a href="http://blogs.lessthandot.com/index.php/DataMgmt/?p=1558">SQL Server Auditing: Creating a Server Specification</a><br />
<a href="http://blogs.lessthandot.com/index.php/DataMgmt/?p=1568">SQL Server Auditing: Creating a Database Specification</a><br />
<a href="http://blogs.lessthandot.com/index.php/DataMgmt/?p=1573">SQL Server Auditing: Managing Your Audits</a></p>


<p><em>Note. Keep an eye on LessThanDot.com to see some cool things happen to the audit repository!!!</em></p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-looking-back">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-looking-back#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1585</wfw:commentRss>
		</item>
				<item>
			<title>SQL Server Auditing: Managing Your Audits</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-managing-your</link>
			<pubDate>Mon, 02 Jan 2012 18:40:00 +0000</pubDate>			<dc:creator>SQLArcher</dc:creator>
			<category domain="main">Database Administration</category>
<category domain="alt">Microsoft SQL Server Admin</category>			<guid isPermaLink="false">1573@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;So far in the SQL Server Audit series we&#039;ve looked at the different components that make up the auditing feature as well as how to create the audits with specifications specific to databases as well as server level. &lt;/p&gt;

&lt;p&gt;Here is the links to the posts covering the topics:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/All/?p=1557&quot;&gt;SQL Server Auditing: Introduction&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://blogs.lessthandot.com/index.php/All/?p=1558&quot;&gt;SQL Server Auditing: Creating a Server Specification&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://blogs.lessthandot.com/index.php/All/?p=1568&quot;&gt;SQL Server Auditing: Creating a Database Specification&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;Now that we have set up our audits covering failed logins on instance level and deletes on database level, let&#039;s take a look at how we can see what audits are on a server as well as some views to make your life easier with reading the audit files.&lt;/p&gt;

&lt;h3&gt;DMV&#039;s and Views&lt;/h3&gt;

&lt;p&gt;First off, let&#039;s see what views are available at our disposal:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb67308&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;USE&lt;/span&gt; master;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; name,&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;all_objects&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;TYPE&lt;/span&gt; = &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;v&#039;&lt;/span&gt; AND NAME LIKE &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;%audit%&#039;&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb80119&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This returns the following for us:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/Management/Results.jpg?mtime=1325273512&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/Management/Results.jpg?mtime=1325273512&quot; width=&quot;307&quot; height=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;


&lt;h4&gt;DMV&#039;s&lt;/h4&gt;

&lt;p&gt;So what does the audit DMV&#039;s do? Let&#039;s take a look:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;sys.dm_audit_actions&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This DMV contains friendlier names, as well as all the actions as well as which action groups they belong to across database and server level specifications.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;sys.dm_audit_class_type_map&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This contains all the audit classes and action groups available.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;sys.dm_server_audit_status&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This takes a specific look at the audits defined on the server and returns info such as what audits are enabled, statuses for the audits, event times, etc.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Sys.dm_audit_class_type_map and sys.dm_audit_actions are especially useful to join with the other views to get a more easily readable report on the audits, or to join it with the fn_get_audit_file function when reading audit files.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;Server Views&lt;/h4&gt;

&lt;p&gt;The server views are split up into two &quot;sections&quot;, one for the audits, and the second for the server specification details.&lt;/p&gt;

&lt;p&gt;Audits:&lt;br /&gt;
&lt;em&gt;sys.server_audits&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;sys.server_file_audits&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;These views contain details about the server level audits defined on the server, This returns information such as audit names, file names and paths, audit id&#039;s, statuses, etc.&lt;/p&gt;

&lt;p&gt;Specification:&lt;br /&gt;
sys.server_audit_specification_details&lt;br /&gt;
sys.server_audit_specifications&lt;/p&gt;

&lt;p&gt;These views are very helpful when you have multiple audits on a server, and matching the various defined audit actions as well as their groups to audits.&lt;/p&gt;


&lt;h4&gt;Database Views&lt;/h4&gt;

&lt;p&gt;The database views available are almost identical to the server level ones, except the fact that it&#039;s specific to databases, and that there are no &quot;audit&quot; views; only for database specifications. Another thing to note is, that these views won&#039;t return information across databases on an instance, this needs to be executed per database.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;sys.database_audit_specification_details&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;sys.database_audit_specifications&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The views return the specification names, enabled audit actions, audit results, etc.&lt;/p&gt;

&lt;p&gt;Now that we&#039;ve got the views covered, a question still lingers... &quot;How do we manage audits across multiple servers?&quot; Well the answer is quite simple, we make use of another new feature introduced in SQL Server 2008 which is Policy Based Management, otherwise known as PBM.&lt;/p&gt;

&lt;p&gt;So PBM is a subject on it&#039;s own, so I will not go in depth into this topic.&lt;/p&gt;

&lt;p&gt;A key resource required for monitoring your environment is the &lt;a href=&quot;http://epmframework.codeplex.com/&quot;&gt;Enterprise Policy Framework&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Below is a test policy I created for the post and will monitor the audits for the following:&lt;/p&gt;

&lt;p&gt;1. Maximum File Size&lt;br /&gt;
2. On Failure Action&lt;br /&gt;
3. Reserve Disk Space&lt;br /&gt;
4. Maximum Rollover Files&lt;br /&gt;
5. Maximum File Size Unit ( MB, GB or TB )&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb59988&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;-- Creates the policy condition&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @condition_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_condition&lt;/span&gt; @name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit_Policy_Con&#039;&lt;/span&gt;, @description=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @facet=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit&#039;&lt;/span&gt;, @expression=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;OpType&amp;gt;AND&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;AND&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;AND&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;AND&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;MaximumFileSize&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.Double&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;100&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;OnFailure&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;FunctionType&amp;gt;Enum&amp;lt;/FunctionType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ReturnType&amp;gt;Numeric&amp;lt;/ReturnType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.String&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;Microsoft.SqlServer.Management.Smo.OnFailureAction&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.String&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;Continue&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;ReserveDiskSpace&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;FunctionType&amp;gt;False&amp;lt;/FunctionType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ReturnType&amp;gt;Bool&amp;lt;/ReturnType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;0&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;MaximumRolloverFiles&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.Double&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;100&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;OpType&amp;gt;EQ&amp;lt;/OpType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Name&amp;gt;MaximumFileSizeUnit&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Attribute&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;Numeric&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;FunctionType&amp;gt;Enum&amp;lt;/FunctionType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ReturnType&amp;gt;Numeric&amp;lt;/ReturnType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.String&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;Microsoft.SqlServer.Management.Smo.AuditFileSizeUnit&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ObjType&amp;gt;System.String&amp;lt;/ObjType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Value&amp;gt;Mb&amp;lt;/Value&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Constant&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Function&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt; &amp;nbsp;&amp;lt;/Operator&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;lt;/Operator&amp;gt;&#039;&lt;/span&gt;, @is_name_condition=&lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;, @obj_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @condition_id=@condition_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @condition_id&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;-- Creates the Policy&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @object_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_object_set&lt;/span&gt; @object_set_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit_Policy_ObjectSet&#039;&lt;/span&gt;, @facet=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit&#039;&lt;/span&gt;, @object_set_id=@object_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @object_set_id&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @target_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_target_set&lt;/span&gt; @object_set_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit_Policy_ObjectSet&#039;&lt;/span&gt;, @type_skeleton=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Server/Audit&#039;&lt;/span&gt;, @&lt;span style=&quot;color: #0000FF;&quot;&gt;type&lt;/span&gt;=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;AUDIT&#039;&lt;/span&gt;, @enabled=&lt;span style=&quot;color: #0000FF;&quot;&gt;True&lt;/span&gt;, @target_set_id=@target_set_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @target_set_id&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_target_set_level&lt;/span&gt; @target_set_id=@target_set_id, @type_skeleton=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Server/Audit&#039;&lt;/span&gt;, @level_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit&#039;&lt;/span&gt;, @condition_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @target_set_level_id=&lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @policy_id &lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; msdb.&lt;span style=&quot;color: #202020;&quot;&gt;dbo&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;sp_syspolicy_add_policy&lt;/span&gt; @name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit_Policy&#039;&lt;/span&gt;, @condition_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit_Policy_Con&#039;&lt;/span&gt;, @policy_category=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @description=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @help_text=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @help_link=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @schedule_uid=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;00000000-0000-0000-0000-000000000000&#039;&lt;/span&gt;, @execution_mode=&lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;, @is_enabled=&lt;span style=&quot;color: #0000FF;&quot;&gt;False&lt;/span&gt;, @policy_id=@policy_id &lt;span style=&quot;color: #0000FF;&quot;&gt;OUTPUT&lt;/span&gt;, @root_condition_name=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, @object_set=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Audit_Policy_ObjectSet&#039;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @policy_id&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb2662&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is just a basic policy using the &quot;audit&quot; facet. There are additional facets for Database Audit Specifications as well as Server Audit Specifications.&lt;/p&gt;

&lt;p&gt;Additionally if you decide to use the Enterprise Policy Framework, it should be noted that you need an additional condition to be set up on the policy that will only evaluate the policy against SQL Server 2008+.&lt;/p&gt;


&lt;h3&gt;Last Thoughts&lt;/h3&gt;

&lt;p&gt;These are the views we can use to discover what audits are running across an instance or databases, which actions we are auditing for and a brief policy we can use when we have to manage the audit files specifically to ensure we have a set standard.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-managing-your&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>So far in the SQL Server Audit series we've looked at the different components that make up the auditing feature as well as how to create the audits with specifications specific to databases as well as server level. </p>

<p>Here is the links to the posts covering the topics:</p>

<p><a href="http://blogs.lessthandot.com/index.php/All/?p=1557">SQL Server Auditing: Introduction</a><br />
<a href="http://blogs.lessthandot.com/index.php/All/?p=1558">SQL Server Auditing: Creating a Server Specification</a><br />
<a href="http://blogs.lessthandot.com/index.php/All/?p=1568">SQL Server Auditing: Creating a Database Specification</a></p>


<p>Now that we have set up our audits covering failed logins on instance level and deletes on database level, let's take a look at how we can see what audits are on a server as well as some views to make your life easier with reading the audit files.</p>

<h3>DMV's and Views</h3>

<p>First off, let's see what views are available at our disposal:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb54900'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb54900','cb41419'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb54900" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">USE</span> master;</li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1"><span style="color: #0000FF;">SELECT</span> name,<span style="color: #808080;">&#91;</span><span style="color: #FF00FF;">object_id</span><span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">FROM</span> <span style="color: #808080;">&#91;</span><span style="color: #00AF00;">sys</span><span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span><span style="color: #00AF00;">all_objects</span><span style="color: #808080;">&#93;</span></li><li style="" class="li2"><span style="color: #0000FF;">WHERE</span> <span style="color: #0000FF;">TYPE</span> = <span style="color: #FF0000;">'v'</span> AND NAME LIKE <span style="color: #FF0000;">'%audit%'</span>;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li></ol></div><div id="cb41419" style="display: none; color: red;"></div></div></div>

<p>This returns the following for us:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/Management/Results.jpg?mtime=1325273512"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/Management/Results.jpg?mtime=1325273512" width="307" height="192" /></a></div>


<h4>DMV's</h4>

<p>So what does the audit DMV's do? Let's take a look:</p>

<p><em>sys.dm_audit_actions</em></p>

<p>This DMV contains friendlier names, as well as all the actions as well as which action groups they belong to across database and server level specifications.</p>

<p><em>sys.dm_audit_class_type_map</em></p>

<p>This contains all the audit classes and action groups available.</p>

<p><em>sys.dm_server_audit_status</em></p>

<p>This takes a specific look at the audits defined on the server and returns info such as what audits are enabled, statuses for the audits, event times, etc.</p>

<p><em>Sys.dm_audit_class_type_map and sys.dm_audit_actions are especially useful to join with the other views to get a more easily readable report on the audits, or to join it with the fn_get_audit_file function when reading audit files.</em></p>

<h4>Server Views</h4>

<p>The server views are split up into two "sections", one for the audits, and the second for the server specification details.</p>

<p>Audits:<br />
<em>sys.server_audits</em><br />
<em>sys.server_file_audits</em></p>

<p>These views contain details about the server level audits defined on the server, This returns information such as audit names, file names and paths, audit id's, statuses, etc.</p>

<p>Specification:<br />
sys.server_audit_specification_details<br />
sys.server_audit_specifications</p>

<p>These views are very helpful when you have multiple audits on a server, and matching the various defined audit actions as well as their groups to audits.</p>


<h4>Database Views</h4>

<p>The database views available are almost identical to the server level ones, except the fact that it's specific to databases, and that there are no "audit" views; only for database specifications. Another thing to note is, that these views won't return information across databases on an instance, this needs to be executed per database.</p>

<p><em>sys.database_audit_specification_details</em><br />
<em>sys.database_audit_specifications</em></p>

<p>The views return the specification names, enabled audit actions, audit results, etc.</p>

<p>Now that we've got the views covered, a question still lingers... "How do we manage audits across multiple servers?" Well the answer is quite simple, we make use of another new feature introduced in SQL Server 2008 which is Policy Based Management, otherwise known as PBM.</p>

<p>So PBM is a subject on it's own, so I will not go in depth into this topic.</p>

<p>A key resource required for monitoring your environment is the <a href="http://epmframework.codeplex.com/">Enterprise Policy Framework</a>.</p>

<p>Below is a test policy I created for the post and will monitor the audits for the following:</p>

<p>1. Maximum File Size<br />
2. On Failure Action<br />
3. Reserve Disk Space<br />
4. Maximum Rollover Files<br />
5. Maximum File Size Unit ( MB, GB or TB )</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb88395'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb88395','cb76654'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb88395" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #00AF00;">-- Creates the policy condition</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">Declare</span> @condition_id <span style="color: #0000FF;">int</span></li><li style="" class="li2"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_condition</span> @name=N<span style="color: #FF0000;">'Audit_Policy_Con'</span>, @description=N<span style="color: #FF0000;">''</span>, @facet=N<span style="color: #FF0000;">'Audit'</span>, @expression=N<span style="color: #FF0000;">'&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;OpType&gt;AND&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;OpType&gt;AND&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;OpType&gt;AND&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;OpType&gt;AND&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Name&gt;MaximumFileSize&lt;/Name&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.Double&lt;/ObjType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;100&lt;/Value&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Name&gt;OnFailure&lt;/Name&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Function&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;FunctionType&gt;Enum&lt;/FunctionType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ReturnType&gt;Numeric&lt;/ReturnType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.String&lt;/ObjType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;Microsoft.SqlServer.Management.Smo.OnFailureAction&lt;/Value&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.String&lt;/ObjType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;Continue&lt;/Value&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Function&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Name&gt;ReserveDiskSpace&lt;/Name&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Function&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;FunctionType&gt;False&lt;/FunctionType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ReturnType&gt;Bool&lt;/ReturnType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Count&gt;0&lt;/Count&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Function&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Name&gt;MaximumRolloverFiles&lt;/Name&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.Double&lt;/ObjType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;100&lt;/Value&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;TypeClass&gt;Bool&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;OpType&gt;EQ&lt;/OpType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Attribute&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Name&gt;MaximumFileSizeUnit&lt;/Name&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Attribute&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;Function&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;Numeric&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;FunctionType&gt;Enum&lt;/FunctionType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;ReturnType&gt;Numeric&lt;/ReturnType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Count&gt;2&lt;/Count&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.String&lt;/ObjType&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;Microsoft.SqlServer.Management.Smo.AuditFileSizeUnit&lt;/Value&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;TypeClass&gt;String&lt;/TypeClass&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;ObjType&gt;System.String&lt;/ObjType&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp; &nbsp;&lt;Value&gt;Mb&lt;/Value&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp; &nbsp; &nbsp;&lt;/Constant&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;"> &nbsp; &nbsp;&lt;/Function&gt;</span></li><li style="" class="li1"><span style="color: #FF0000;"> &nbsp;&lt;/Operator&gt;</span></li><li style="" class="li2"><span style="color: #FF0000;">&lt;/Operator&gt;'</span>, @is_name_condition=<span style="color: #000;">0</span>, @obj_name=N<span style="color: #FF0000;">''</span>, @condition_id=@condition_id <span style="color: #0000FF;">OUTPUT</span></li><li style="" class="li1"><span style="color: #0000FF;">Select</span> @condition_id</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #00AF00;">-- Creates the Policy</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">Declare</span> @object_set_id <span style="color: #0000FF;">int</span></li><li style="" class="li2"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_object_set</span> @object_set_name=N<span style="color: #FF0000;">'Audit_Policy_ObjectSet'</span>, @facet=N<span style="color: #FF0000;">'Audit'</span>, @object_set_id=@object_set_id <span style="color: #0000FF;">OUTPUT</span></li><li style="" class="li1"><span style="color: #0000FF;">Select</span> @object_set_id</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">Declare</span> @target_set_id <span style="color: #0000FF;">int</span></li><li style="" class="li2"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_target_set</span> @object_set_name=N<span style="color: #FF0000;">'Audit_Policy_ObjectSet'</span>, @type_skeleton=N<span style="color: #FF0000;">'Server/Audit'</span>, @<span style="color: #0000FF;">type</span>=N<span style="color: #FF0000;">'AUDIT'</span>, @enabled=<span style="color: #0000FF;">True</span>, @target_set_id=@target_set_id <span style="color: #0000FF;">OUTPUT</span></li><li style="" class="li1"><span style="color: #0000FF;">Select</span> @target_set_id</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_target_set_level</span> @target_set_id=@target_set_id, @type_skeleton=N<span style="color: #FF0000;">'Server/Audit'</span>, @level_name=N<span style="color: #FF0000;">'Audit'</span>, @condition_name=N<span style="color: #FF0000;">''</span>, @target_set_level_id=<span style="color: #000;">0</span></li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">Declare</span> @policy_id <span style="color: #0000FF;">int</span></li><li style="" class="li1"><span style="color: #0000FF;">EXEC</span> msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">sp_syspolicy_add_policy</span> @name=N<span style="color: #FF0000;">'Audit_Policy'</span>, @condition_name=N<span style="color: #FF0000;">'Audit_Policy_Con'</span>, @policy_category=N<span style="color: #FF0000;">''</span>, @description=N<span style="color: #FF0000;">''</span>, @help_text=N<span style="color: #FF0000;">''</span>, @help_link=N<span style="color: #FF0000;">''</span>, @schedule_uid=N<span style="color: #FF0000;">'00000000-0000-0000-0000-000000000000'</span>, @execution_mode=<span style="color: #000;">0</span>, @is_enabled=<span style="color: #0000FF;">False</span>, @policy_id=@policy_id <span style="color: #0000FF;">OUTPUT</span>, @root_condition_name=N<span style="color: #FF0000;">''</span>, @object_set=N<span style="color: #FF0000;">'Audit_Policy_ObjectSet'</span></li><li style="" class="li2"><span style="color: #0000FF;">Select</span> @policy_id</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li></ol></div><div id="cb76654" style="display: none; color: red;"></div></div></div>

<p>This is just a basic policy using the "audit" facet. There are additional facets for Database Audit Specifications as well as Server Audit Specifications.</p>

<p>Additionally if you decide to use the Enterprise Policy Framework, it should be noted that you need an additional condition to be set up on the policy that will only evaluate the policy against SQL Server 2008+.</p>


<h3>Last Thoughts</h3>

<p>These are the views we can use to discover what audits are running across an instance or databases, which actions we are auditing for and a brief policy we can use when we have to manage the audit files specifically to ensure we have a set standard.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-managing-your">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-managing-your#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1573</wfw:commentRss>
		</item>
				<item>
			<title>SQL Server Auditing: Creating a Database Specification</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-creating-a-1</link>
			<pubDate>Wed, 28 Dec 2011 05:02:00 +0000</pubDate>			<dc:creator>SQLArcher</dc:creator>
			<category domain="main">Database Administration</category>
<category domain="alt">Microsoft SQL Server Admin</category>			<guid isPermaLink="false">1568@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Continuing onwards with the SQL Server auditing feature, let&#039;s start off by creating a simple audit that will capture some database level events.&lt;/p&gt;

&lt;p&gt;Previously we looked at how to create a Server Audit Specification and creating a Database Specification follows the same steps. The main difference is the location, as well as the objects to capture. In the following example we will look at capturing delete statements on a database.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;It is also important to note, that you cannot audit across databases, you will need to set up a Database Specification and its corresponding Audit per database.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;Creating the Audit&lt;/h3&gt;

&lt;p&gt;We follow the same steps as previously by creating the Audit file:&lt;/p&gt;

&lt;p&gt;Expand your instance &gt;&gt; Security &gt;&gt; Right-Click the audit folder &gt;&gt; Select New Audit&lt;/p&gt;

&lt;p&gt;This should bring up a new window similar to this:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/AuditFilejpg.jpg?mtime=1325055918&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/AuditFilejpg.jpg?mtime=1325055918&quot; width=&quot;650&quot; height=&quot;584&quot; /&gt;&lt;/a&gt;&lt;/div&gt;



&lt;h3&gt;Creating the Specification&lt;/h3&gt;

&lt;p&gt;To Create a Database Specification you can find it under:&lt;/p&gt;

&lt;p&gt;Database &gt;&gt; Security &gt;&gt; Database Audit Specification&lt;/p&gt;

&lt;p&gt;The first configuration I have for the Database Specification, I am capturing on a database level, only deletes, and only when executed by user belonging to the db_datawriter role.&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/DBSpec_1.jpg?mtime=1325062219&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/DBSpec_1.jpg?mtime=1325062219&quot; width=&quot;856&quot; height=&quot;152&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;I executed the following query on my account which is sysadmin:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb87455&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;USE&lt;/span&gt; testdb;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;DELETE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; tab1 &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; id BETWEEN &lt;span style=&quot;color: #000;&quot;&gt;9990&lt;/span&gt; AND &lt;span style=&quot;color: #000;&quot;&gt;10000&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;DELETE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; tab2 &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; id BETWEEN &lt;span style=&quot;color: #000;&quot;&gt;5000&lt;/span&gt; AND &lt;span style=&quot;color: #000;&quot;&gt;5100&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;DELETE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; tab3 &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; id BETWEEN &lt;span style=&quot;color: #000;&quot;&gt;2000&lt;/span&gt; AND &lt;span style=&quot;color: #000;&quot;&gt;2002&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb23698&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This resulted in no deletes being captured:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/result1.jpg?mtime=1325057639&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/result1.jpg?mtime=1325057639&quot; width=&quot;902&quot; height=&quot;171&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;When executed as test_writer, which belongs to the db_datawriter role and I execute the following:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb71826&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;USE&lt;/span&gt; testdb;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;DELETE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; tab1 &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; id BETWEEN &lt;span style=&quot;color: #000;&quot;&gt;9900&lt;/span&gt; AND &lt;span style=&quot;color: #000;&quot;&gt;9990&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;DELETE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; tab2 &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; id BETWEEN &lt;span style=&quot;color: #000;&quot;&gt;4500&lt;/span&gt; AND &lt;span style=&quot;color: #000;&quot;&gt;4990&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;DELETE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; tab3 &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; id BETWEEN &lt;span style=&quot;color: #000;&quot;&gt;2500&lt;/span&gt; AND &lt;span style=&quot;color: #000;&quot;&gt;2560&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb92236&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I receive the following results:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/result2.jpg?mtime=1325057650&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/result2.jpg?mtime=1325057650&quot; width=&quot;1099&quot; height=&quot;130&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;One thing to note on the output is under &quot;audit_file_offset&quot;. All three values are 6144, which indicates that the three statements where executed in the same query.&lt;/em&gt;&lt;/p&gt;


&lt;p&gt;As with the Server Audits, use the following query to retrieve the audit information as it is displayed above:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb56498&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; &amp;nbsp;event_time ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; action_id ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; succeeded ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; session_id ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; server_principal_name ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; server_instance_name ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; database_name ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;statement&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; audit_file_offset&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #00AF00;&quot;&gt;fn_get_audit_file&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;E:\SQLAuditing\DBAudit*.sqlaudit&#039;&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb18357&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The second example is just to audit a specific table:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/DBSpec_2.jpg?mtime=1325062315&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/DBSpec_2.jpg?mtime=1325062315&quot; width=&quot;853&quot; height=&quot;154&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Note the areas in the red squares, it changes to audit objects, then a specific table, and lastly to which principle it should be bound and again in this case it will be db_datawriter.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Again, I execute a delete statement:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb1230&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;USE&lt;/span&gt; testdb;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;DELETE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; tab1 &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; id BETWEEN &lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt; AND &lt;span style=&quot;color: #000;&quot;&gt;100&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;DELETE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; tab2 &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; id BETWEEN &lt;span style=&quot;color: #000;&quot;&gt;400&lt;/span&gt; AND &lt;span style=&quot;color: #000;&quot;&gt;6000&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;DELETE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; tab3 &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; id BETWEEN &lt;span style=&quot;color: #000;&quot;&gt;7000&lt;/span&gt; AND &lt;span style=&quot;color: #000;&quot;&gt;7050&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb48855&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Inspecting the statement column, we can see that it only captured the delete statement that was executed against tab1:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/result3.jpg?mtime=1325062845&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/result3.jpg?mtime=1325062845&quot; width=&quot;1087&quot; height=&quot;89&quot; /&gt;&lt;/a&gt;&lt;/div&gt;



&lt;p&gt;To create the users, database, and populate it with the data I used - run the following:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb72440&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;/*Creates the database and the logins*/&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;USE&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;master&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;IF&lt;/span&gt; EXISTS&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; NAME &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; master.&lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;server_principals&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; name = &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;testuser&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;DROP&lt;/span&gt; LOGIN testuser;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;IF&lt;/span&gt; EXISTS&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; NAME &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; master.&lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;server_principals&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; name = &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;test_writer&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;DROP&lt;/span&gt; LOGIN test_writer;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;IF&lt;/span&gt; EXISTS&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; NAME &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; master.&lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;databases&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; name = &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;testdb&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;DROP&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;DATABASE&lt;/span&gt; testdb;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CREATE&lt;/span&gt; LOGIN &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;testuser&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;WITH&lt;/span&gt; PASSWORD=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;password&#039;&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT_DATABASE&lt;/span&gt;=&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;master&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT_LANGUAGE&lt;/span&gt;=&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;us_english&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;,&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CHECK_EXPIRATION&lt;/span&gt;=&lt;span style=&quot;color: #0000FF;&quot;&gt;OFF&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;CHECK_POLICY&lt;/span&gt;=&lt;span style=&quot;color: #0000FF;&quot;&gt;OFF&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ALTER&lt;/span&gt; LOGIN &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;testuser&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; ENABLE&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CREATE&lt;/span&gt; LOGIN &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;test_writer&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;WITH&lt;/span&gt; PASSWORD=N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;password&#039;&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT_DATABASE&lt;/span&gt;=&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;master&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT_LANGUAGE&lt;/span&gt;=&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;us_english&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;,&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CHECK_EXPIRATION&lt;/span&gt;=&lt;span style=&quot;color: #0000FF;&quot;&gt;OFF&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;CHECK_POLICY&lt;/span&gt;=&lt;span style=&quot;color: #0000FF;&quot;&gt;OFF&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ALTER&lt;/span&gt; LOGIN &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;test_writer&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; ENABLE&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;DATABASE&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;testdb&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; ;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;/* Grants the access for the logins */&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;USE&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;testdb&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; ;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;USER&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;testuser&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;FOR&lt;/span&gt; LOGIN &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;testuser&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;WITH&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT_SCHEMA&lt;/span&gt;=&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;dbo&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;USER&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;test_writer&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;FOR&lt;/span&gt; LOGIN &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;test_writer&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;WITH&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT_SCHEMA&lt;/span&gt;=&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;dbo&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; &lt;span style=&quot;color: #AF0000;&quot;&gt;sp_addrolemember&lt;/span&gt; N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;db_owner&#039;&lt;/span&gt;, N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;testuser&#039;&lt;/span&gt; ;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;EXEC&lt;/span&gt; &lt;span style=&quot;color: #AF0000;&quot;&gt;sp_addrolemember&lt;/span&gt; N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;db_datawriter&#039;&lt;/span&gt;, N&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;test_writer&#039;&lt;/span&gt; ;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;/*Creates the test tables */&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;TABLE&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;dbo&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;tab1&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;id&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;IDENTITY&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NOT NULL ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;comment&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;tabdate&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NULL&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt; &amp;nbsp;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;PRIMARY&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;TABLE&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;dbo&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;tab2&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;id&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;IDENTITY&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NOT NULL ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;comment&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;tabdate&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NULL&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt; &amp;nbsp;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;PRIMARY&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;TABLE&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;dbo&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;tab3&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;id&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;IDENTITY&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NOT NULL ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;comment&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NULL ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;tabdate&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NULL&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt; &amp;nbsp;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;PRIMARY&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;USE&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;master&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ALTER&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;DATABASE&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;testdb&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;SET&lt;/span&gt; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;READ_WRITE&lt;/span&gt; &lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;/* Random test data */&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;USE&lt;/span&gt; testdb ;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;INSERT&lt;/span&gt; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;INTO&lt;/span&gt; tab1&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt; comment, tabdate &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;VALUES&lt;/span&gt; &amp;nbsp;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;abcdefg&#039;&lt;/span&gt;, &lt;span style=&quot;color: #FF00FF;&quot;&gt;GETDATE&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt; &lt;span style=&quot;color: #000;&quot;&gt;10000&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;INSERT&lt;/span&gt; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;INTO&lt;/span&gt; tab2&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; &amp;nbsp;comment ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tabdate&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; &amp;nbsp; &amp;nbsp;TAB1 ;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;INSERT&lt;/span&gt; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;INTO&lt;/span&gt; tab3&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; &amp;nbsp;comment ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tabdate&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; &amp;nbsp; &amp;nbsp;TAB1 ;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb23954&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;


&lt;h3&gt;Final Thoughts&lt;/h3&gt;

&lt;p&gt;Just based on auditing for delete statements on database can prove to be very dynamic when using the auditing feature. It doesn&#039;t even stop here, as this was only a demo, there are a lot more you can audit like stored procedures, functions, views, etc. This is a powerful feature especially for monitoring critical and highly sensitive databases.&lt;/p&gt;

&lt;p&gt;To see what else you can audit with the Database Specifications go &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/cc280663.aspx&quot;&gt;here&lt;/a&gt; and skip down to Database-Level Audit Action Groups.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-creating-a-1&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Continuing onwards with the SQL Server auditing feature, let's start off by creating a simple audit that will capture some database level events.</p>

<p>Previously we looked at how to create a Server Audit Specification and creating a Database Specification follows the same steps. The main difference is the location, as well as the objects to capture. In the following example we will look at capturing delete statements on a database.</p>

<p><em>It is also important to note, that you cannot audit across databases, you will need to set up a Database Specification and its corresponding Audit per database.</em></p>

<h3>Creating the Audit</h3>

<p>We follow the same steps as previously by creating the Audit file:</p>

<p>Expand your instance >> Security >> Right-Click the audit folder >> Select New Audit</p>

<p>This should bring up a new window similar to this:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/AuditFilejpg.jpg?mtime=1325055918"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/AuditFilejpg.jpg?mtime=1325055918" width="650" height="584" /></a></div>



<h3>Creating the Specification</h3>

<p>To Create a Database Specification you can find it under:</p>

<p>Database >> Security >> Database Audit Specification</p>

<p>The first configuration I have for the Database Specification, I am capturing on a database level, only deletes, and only when executed by user belonging to the db_datawriter role.</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/DBSpec_1.jpg?mtime=1325062219"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/DBSpec_1.jpg?mtime=1325062219" width="856" height="152" /></a></div>

<p>I executed the following query on my account which is sysadmin:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb86208'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb86208','cb92268'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb86208" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">USE</span> testdb;</li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">DELETE</span> <span style="color: #0000FF;">FROM</span> tab1 <span style="color: #0000FF;">WHERE</span> id BETWEEN <span style="color: #000;">9990</span> AND <span style="color: #000;">10000</span>;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2"><span style="color: #0000FF;">DELETE</span> <span style="color: #0000FF;">FROM</span> tab2 <span style="color: #0000FF;">WHERE</span> id BETWEEN <span style="color: #000;">5000</span> AND <span style="color: #000;">5100</span>;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2"><span style="color: #0000FF;">DELETE</span> <span style="color: #0000FF;">FROM</span> tab3 <span style="color: #0000FF;">WHERE</span> id BETWEEN <span style="color: #000;">2000</span> AND <span style="color: #000;">2002</span>;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li></ol></div><div id="cb92268" style="display: none; color: red;"></div></div></div>

<p>This resulted in no deletes being captured:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/result1.jpg?mtime=1325057639"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/result1.jpg?mtime=1325057639" width="902" height="171" /></a></div>

<p>When executed as test_writer, which belongs to the db_datawriter role and I execute the following:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb36868'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb36868','cb41241'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb36868" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">USE</span> testdb;</li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">DELETE</span> <span style="color: #0000FF;">FROM</span> tab1 <span style="color: #0000FF;">WHERE</span> id BETWEEN <span style="color: #000;">9900</span> AND <span style="color: #000;">9990</span>;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2"><span style="color: #0000FF;">DELETE</span> <span style="color: #0000FF;">FROM</span> tab2 <span style="color: #0000FF;">WHERE</span> id BETWEEN <span style="color: #000;">4500</span> AND <span style="color: #000;">4990</span>;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2"><span style="color: #0000FF;">DELETE</span> <span style="color: #0000FF;">FROM</span> tab3 <span style="color: #0000FF;">WHERE</span> id BETWEEN <span style="color: #000;">2500</span> AND <span style="color: #000;">2560</span>;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li></ol></div><div id="cb41241" style="display: none; color: red;"></div></div></div>

<p>I receive the following results:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/result2.jpg?mtime=1325057650"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/result2.jpg?mtime=1325057650" width="1099" height="130" /></a></div>

<p><em>One thing to note on the output is under "audit_file_offset". All three values are 6144, which indicates that the three statements where executed in the same query.</em></p>


<p>As with the Server Audits, use the following query to retrieve the audit information as it is displayed above:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb18227'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb18227','cb83751'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb18227" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">SELECT</span> &nbsp;event_time ,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; action_id ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; succeeded ,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; session_id ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; server_principal_name ,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; server_instance_name ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; database_name ,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">statement</span><span style="color: #808080;">&#93;</span> ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; audit_file_offset</li><li style="" class="li2"><span style="color: #0000FF;">FROM</span> &nbsp; &nbsp;<span style="color: #00AF00;">fn_get_audit_file</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'E:\SQLAuditing\DBAudit*.sqlaudit'</span>,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">DEFAULT</span>, <span style="color: #0000FF;">DEFAULT</span><span style="color: #808080;">&#41;</span></li></ol></div><div id="cb83751" style="display: none; color: red;"></div></div></div>

<p>The second example is just to audit a specific table:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/DBSpec_2.jpg?mtime=1325062315"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/DBSpec_2.jpg?mtime=1325062315" width="853" height="154" /></a></div>

<p><em>Note the areas in the red squares, it changes to audit objects, then a specific table, and lastly to which principle it should be bound and again in this case it will be db_datawriter.</em></p>

<p>Again, I execute a delete statement:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb42005'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb42005','cb23490'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb42005" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">USE</span> testdb;</li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">DELETE</span> <span style="color: #0000FF;">FROM</span> tab1 <span style="color: #0000FF;">WHERE</span> id BETWEEN <span style="color: #000;">1</span> AND <span style="color: #000;">100</span>;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2"><span style="color: #0000FF;">DELETE</span> <span style="color: #0000FF;">FROM</span> tab2 <span style="color: #0000FF;">WHERE</span> id BETWEEN <span style="color: #000;">400</span> AND <span style="color: #000;">6000</span>;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2"><span style="color: #0000FF;">DELETE</span> <span style="color: #0000FF;">FROM</span> tab3 <span style="color: #0000FF;">WHERE</span> id BETWEEN <span style="color: #000;">7000</span> AND <span style="color: #000;">7050</span>;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li></ol></div><div id="cb23490" style="display: none; color: red;"></div></div></div>

<p>Inspecting the statement column, we can see that it only captured the delete statement that was executed against tab1:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/result3.jpg?mtime=1325062845"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/DatabaseSpec/result3.jpg?mtime=1325062845" width="1087" height="89" /></a></div>



<p>To create the users, database, and populate it with the data I used - run the following:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb54164'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb54164','cb43448'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb54164" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #00AF00;">/*Creates the database and the logins*/</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">USE</span> <span style="color: #808080;">&#91;</span>master<span style="color: #808080;">&#93;</span></li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">IF</span> EXISTS<span style="color: #808080;">&#40;</span><span style="color: #0000FF;">SELECT</span> NAME <span style="color: #0000FF;">FROM</span> master.<span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">server_principals</span> <span style="color: #0000FF;">WHERE</span> name = <span style="color: #FF0000;">'testuser'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">DROP</span> LOGIN testuser;</li><li style="" class="li2"><span style="color: #0000FF;">IF</span> EXISTS<span style="color: #808080;">&#40;</span><span style="color: #0000FF;">SELECT</span> NAME <span style="color: #0000FF;">FROM</span> master.<span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">server_principals</span> <span style="color: #0000FF;">WHERE</span> name = <span style="color: #FF0000;">'test_writer'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">DROP</span> LOGIN test_writer;</li><li style="" class="li2"><span style="color: #0000FF;">IF</span> EXISTS<span style="color: #808080;">&#40;</span><span style="color: #0000FF;">SELECT</span> NAME <span style="color: #0000FF;">FROM</span> master.<span style="color: #00AF00;">sys</span>.<span style="color: #202020;">databases</span> <span style="color: #0000FF;">WHERE</span> name = <span style="color: #FF0000;">'testdb'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">DROP</span> <span style="color: #0000FF;">DATABASE</span> testdb;</li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">CREATE</span> LOGIN <span style="color: #808080;">&#91;</span>testuser<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">WITH</span> PASSWORD=N<span style="color: #FF0000;">'password'</span>, <span style="color: #0000FF;">DEFAULT_DATABASE</span>=<span style="color: #808080;">&#91;</span>master<span style="color: #808080;">&#93;</span>, <span style="color: #0000FF;">DEFAULT_LANGUAGE</span>=<span style="color: #808080;">&#91;</span>us_english<span style="color: #808080;">&#93;</span>,</li><li style="" class="li1"><span style="color: #0000FF;">CHECK_EXPIRATION</span>=<span style="color: #0000FF;">OFF</span>, <span style="color: #0000FF;">CHECK_POLICY</span>=<span style="color: #0000FF;">OFF</span></li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">ALTER</span> LOGIN <span style="color: #808080;">&#91;</span>testuser<span style="color: #808080;">&#93;</span> ENABLE</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">CREATE</span> LOGIN <span style="color: #808080;">&#91;</span>test_writer<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">WITH</span> PASSWORD=N<span style="color: #FF0000;">'password'</span>, <span style="color: #0000FF;">DEFAULT_DATABASE</span>=<span style="color: #808080;">&#91;</span>master<span style="color: #808080;">&#93;</span>, <span style="color: #0000FF;">DEFAULT_LANGUAGE</span>=<span style="color: #808080;">&#91;</span>us_english<span style="color: #808080;">&#93;</span>,</li><li style="" class="li2"><span style="color: #0000FF;">CHECK_EXPIRATION</span>=<span style="color: #0000FF;">OFF</span>, <span style="color: #0000FF;">CHECK_POLICY</span>=<span style="color: #0000FF;">OFF</span></li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">ALTER</span> LOGIN <span style="color: #808080;">&#91;</span>test_writer<span style="color: #808080;">&#93;</span> ENABLE</li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">DATABASE</span> <span style="color: #808080;">&#91;</span>testdb<span style="color: #808080;">&#93;</span> ;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #00AF00;">/* Grants the access for the logins */</span></li><li style="" class="li2"><span style="color: #0000FF;">USE</span> <span style="color: #808080;">&#91;</span>testdb<span style="color: #808080;">&#93;</span> ;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">USER</span> <span style="color: #808080;">&#91;</span>testuser<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">FOR</span> LOGIN <span style="color: #808080;">&#91;</span>testuser<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">WITH</span> <span style="color: #0000FF;">DEFAULT_SCHEMA</span>=<span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span></li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">USER</span> <span style="color: #808080;">&#91;</span>test_writer<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">FOR</span> LOGIN <span style="color: #808080;">&#91;</span>test_writer<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">WITH</span> <span style="color: #0000FF;">DEFAULT_SCHEMA</span>=<span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span></li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1"><span style="color: #0000FF;">EXEC</span> <span style="color: #AF0000;">sp_addrolemember</span> N<span style="color: #FF0000;">'db_owner'</span>, N<span style="color: #FF0000;">'testuser'</span> ;</li><li style="" class="li2"><span style="color: #0000FF;">EXEC</span> <span style="color: #AF0000;">sp_addrolemember</span> N<span style="color: #FF0000;">'db_datawriter'</span>, N<span style="color: #FF0000;">'test_writer'</span> ;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #00AF00;">/*Creates the test tables */</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>tab1<span style="color: #808080;">&#93;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#40;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#91;</span>id<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">int</span><span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">IDENTITY</span><span style="color: #808080;">&#40;</span><span style="color: #000;">1</span>, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NOT NULL ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#91;</span>comment<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">10</span><span style="color: #808080;">&#41;</span> NULL ,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#91;</span>tabdate<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">date</span><span style="color: #808080;">&#93;</span> NULL</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">ON</span> &nbsp;<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">PRIMARY</span><span style="color: #808080;">&#93;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>tab2<span style="color: #808080;">&#93;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#40;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#91;</span>id<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">int</span><span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">IDENTITY</span><span style="color: #808080;">&#40;</span><span style="color: #000;">1</span>, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NOT NULL ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#91;</span>comment<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">10</span><span style="color: #808080;">&#41;</span> NULL ,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#91;</span>tabdate<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">date</span><span style="color: #808080;">&#93;</span> NULL</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">ON</span> &nbsp;<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">PRIMARY</span><span style="color: #808080;">&#93;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>tab3<span style="color: #808080;">&#93;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#40;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#91;</span>id<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">int</span><span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">IDENTITY</span><span style="color: #808080;">&#40;</span><span style="color: #000;">1</span>, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NOT NULL ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#91;</span>comment<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">10</span><span style="color: #808080;">&#41;</span> NULL ,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#91;</span>tabdate<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">date</span><span style="color: #808080;">&#93;</span> NULL</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">ON</span> &nbsp;<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">PRIMARY</span><span style="color: #808080;">&#93;</span></li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">USE</span> <span style="color: #808080;">&#91;</span>master<span style="color: #808080;">&#93;</span></li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1"><span style="color: #0000FF;">ALTER</span> <span style="color: #0000FF;">DATABASE</span> <span style="color: #808080;">&#91;</span>testdb<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">SET</span> &nbsp;<span style="color: #0000FF;">READ_WRITE</span> </li><li style="" class="li2"><span style="color: #0000FF;">GO</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #00AF00;">/* Random test data */</span></li><li style="" class="li2"><span style="color: #0000FF;">USE</span> testdb ;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">INSERT</span> &nbsp;<span style="color: #0000FF;">INTO</span> tab1</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#40;</span> comment, tabdate <span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">VALUES</span> &nbsp;<span style="color: #808080;">&#40;</span> <span style="color: #FF0000;">'abcdefg'</span>, <span style="color: #FF00FF;">GETDATE</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">&#41;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span> <span style="color: #000;">10000</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">INSERT</span> &nbsp;<span style="color: #0000FF;">INTO</span> tab2</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">SELECT</span> &nbsp;comment ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tabdate</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">FROM</span> &nbsp; &nbsp;TAB1 ;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">INSERT</span> &nbsp;<span style="color: #0000FF;">INTO</span> tab3</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">SELECT</span> &nbsp;comment ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tabdate</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">FROM</span> &nbsp; &nbsp;TAB1 ;</li><li style="" class="li1"><span style="color: #0000FF;">GO</span></li></ol></div><div id="cb43448" style="display: none; color: red;"></div></div></div>


<h3>Final Thoughts</h3>

<p>Just based on auditing for delete statements on database can prove to be very dynamic when using the auditing feature. It doesn't even stop here, as this was only a demo, there are a lot more you can audit like stored procedures, functions, views, etc. This is a powerful feature especially for monitoring critical and highly sensitive databases.</p>

<p>To see what else you can audit with the Database Specifications go <a href="http://msdn.microsoft.com/en-us/library/cc280663.aspx">here</a> and skip down to Database-Level Audit Action Groups.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-creating-a-1">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-creating-a-1#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1568</wfw:commentRss>
		</item>
				<item>
			<title>SQL Server Auditing: Creating a Server Specification</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-creating-a</link>
			<pubDate>Wed, 21 Dec 2011 08:01:00 +0000</pubDate>			<dc:creator>SQLArcher</dc:creator>
			<category domain="main">Database Administration</category>
<category domain="alt">Microsoft SQL Server Admin</category>			<guid isPermaLink="false">1558@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Continuing onwards with the SQL Server auditing feature, let&#039;s start off by creating a simple audit that will capture some server level events.&lt;/p&gt;

&lt;p&gt;As a DBA one of the things to know is when login attempts are made, and which ones is failing as it could be someone unauthorized trying to gain access . This can be easily retrieved from the SQL error log, however we want to keep track of these events over a period of time, there for the error log might not suffice.&lt;/p&gt;

&lt;p&gt;In other circumstances, the system can be under certain policies and regulations which requires you to keep the data for a set amount of time, and we don&#039;t want other data that is not as critical to be clutter the data we are actually looking to keep.&lt;/p&gt;


&lt;h3&gt;Creating The Audit&lt;/h3&gt;

&lt;p&gt;To start off with the auditing, we will first set up an audit file. The audit file contains the target destination, file size and max roll over files (only applicable to using a file target) as well as what actions to take when an event triggers.&lt;/p&gt;

&lt;p&gt;Limitations on the auditing file is, that you can only have one audit file per specification. This will leave you with either capturing multiple actions or action groups to one file, or multiple specifications to multiple audit files. You can also not mix a database specification with a server specification to one audit file.&lt;/p&gt;

&lt;p&gt;To create an audit file using SSMS do the following:&lt;/p&gt;

&lt;p&gt;Expand your instance &gt;&gt; Security &gt;&gt; Right-Click the audit folder &gt;&gt; Select New Audit&lt;/p&gt;

&lt;p&gt;This should bring up a new window similar to this:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/ServerSpec/Audit.jpg?mtime=1324455850&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/ServerSpec/Audit.jpg?mtime=1324455850&quot; width=&quot;651&quot; height=&quot;585&quot; /&gt;&lt;/a&gt;&lt;/div&gt;


&lt;h5&gt;On Audit Log Failure&lt;/h5&gt;
&lt;p&gt;Here we can select between the different actions to take based upon what audit action is triggered. We might just want to log all the database option changes, and who made the change, then we will only use CONTINUE or if we don&#039;t allow changes, then we can fail the operation. In more secure environments when we receive certain login failures, the audit mechanism can shut down SQL and prevent a possible security breach.&lt;/p&gt;

&lt;h5&gt;Audit Destination&lt;/h5&gt;
&lt;p&gt;We can choose between file, application, and the security log. The different options visible is only applicable to the file destination as where the application and security log destinations will make use of the settings applied within Windows Server.&lt;/p&gt;

&lt;p&gt;For the file destination there are some handy features like choosing the different sizes and reserving that disk space upfront. In the case of using the audit log due to regulation, it is advised that you keep an eye on the files to ensure that back them up before they are recycled.&lt;/p&gt;

&lt;p&gt;After creating the audit, under the same location - select your audit &gt;&gt; right-click  and select Enable Audit.&lt;/p&gt;

&lt;h3&gt;Creating The Specification&lt;/h3&gt;

&lt;p&gt;So we created our audit, which is now happily running in the background however no audit events are being captured. To capture the events we need to set up either a Server Audit Specification or a Database Audit Specification.&lt;/p&gt;

&lt;p&gt;Now we will set up a Server Audit Specification, under the same security folder in SSMS,&lt;/p&gt;

&lt;p&gt;Right-click Server Audit Specification &gt;&gt; New Server Audit Specification.&lt;/p&gt;

&lt;p&gt;This will bring a window similar to this:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/ServerSpec/Specification.jpg?mtime=1324455868&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/ServerSpec/Specification.jpg?mtime=1324455868&quot; width=&quot;844&quot; height=&quot;299&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;Under Audit can select the audit you have just created. If you have multiple audits all of them will show up, however if you choose one with a specification already assigned, then it will throw an error and warn you.&lt;/p&gt;

&lt;p&gt;You can assign multiple audit actions, or audit action groups to one specification however for this exercise we will only use database_change_group to track database changes.After creating the audit the same steps should be followed to enable the specification.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: It is the default behaviour of Management Studio to create the specifications as well as the audits in an offline state.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So now that both the audit and the specification is in place, I made a few changes to a database and now we can look into the file using the following code:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb60022&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;--returns all the columns for the file&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; * &lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color: #00AF00;&quot;&gt;fn_get_audit_file&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;E:\SQLAuditing\SQLAudit_DBChanges*.sqlaudit&#039;&lt;/span&gt;,&lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT&lt;/span&gt;,&lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #00AF00;&quot;&gt;--Returns specific items to aid in analysing the audit file&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; &amp;nbsp;event_time ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; action_id ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; succeeded ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; session_id ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; server_principal_name ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; server_instance_name ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; database_name ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;statement&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; ,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; audit_file_offset&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #00AF00;&quot;&gt;fn_get_audit_file&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;E:\SQLAuditing\SQLAudit_DBChanges*.sqlaudit&#039;&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;DEFAULT&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb40652&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Note: All the files will be appended with a guid, there for it is easier to use the name and then a wildcard which is * to make it easier to load the file and to read the code.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The output of my test looks like this:&lt;/p&gt;

&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/ServerSpec/FailedResults.jpg?mtime=1324455860&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/ServerSpec/FailedResults.jpg?mtime=1324455860&quot; width=&quot;1081&quot; height=&quot;117&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;This is a quick specification to monitor for failed logins using the Server Audit Specification and to demonstrate how to do it. There is more information for the different action groups to use with the server audit specification &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/cc280663.aspx&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-creating-a&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Continuing onwards with the SQL Server auditing feature, let's start off by creating a simple audit that will capture some server level events.</p>

<p>As a DBA one of the things to know is when login attempts are made, and which ones is failing as it could be someone unauthorized trying to gain access . This can be easily retrieved from the SQL error log, however we want to keep track of these events over a period of time, there for the error log might not suffice.</p>

<p>In other circumstances, the system can be under certain policies and regulations which requires you to keep the data for a set amount of time, and we don't want other data that is not as critical to be clutter the data we are actually looking to keep.</p>


<h3>Creating The Audit</h3>

<p>To start off with the auditing, we will first set up an audit file. The audit file contains the target destination, file size and max roll over files (only applicable to using a file target) as well as what actions to take when an event triggers.</p>

<p>Limitations on the auditing file is, that you can only have one audit file per specification. This will leave you with either capturing multiple actions or action groups to one file, or multiple specifications to multiple audit files. You can also not mix a database specification with a server specification to one audit file.</p>

<p>To create an audit file using SSMS do the following:</p>

<p>Expand your instance >> Security >> Right-Click the audit folder >> Select New Audit</p>

<p>This should bring up a new window similar to this:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/ServerSpec/Audit.jpg?mtime=1324455850"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/ServerSpec/Audit.jpg?mtime=1324455850" width="651" height="585" /></a></div>


<h5>On Audit Log Failure</h5>
<p>Here we can select between the different actions to take based upon what audit action is triggered. We might just want to log all the database option changes, and who made the change, then we will only use CONTINUE or if we don't allow changes, then we can fail the operation. In more secure environments when we receive certain login failures, the audit mechanism can shut down SQL and prevent a possible security breach.</p>

<h5>Audit Destination</h5>
<p>We can choose between file, application, and the security log. The different options visible is only applicable to the file destination as where the application and security log destinations will make use of the settings applied within Windows Server.</p>

<p>For the file destination there are some handy features like choosing the different sizes and reserving that disk space upfront. In the case of using the audit log due to regulation, it is advised that you keep an eye on the files to ensure that back them up before they are recycled.</p>

<p>After creating the audit, under the same location - select your audit >> right-click  and select Enable Audit.</p>

<h3>Creating The Specification</h3>

<p>So we created our audit, which is now happily running in the background however no audit events are being captured. To capture the events we need to set up either a Server Audit Specification or a Database Audit Specification.</p>

<p>Now we will set up a Server Audit Specification, under the same security folder in SSMS,</p>

<p>Right-click Server Audit Specification >> New Server Audit Specification.</p>

<p>This will bring a window similar to this:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/ServerSpec/Specification.jpg?mtime=1324455868"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/ServerSpec/Specification.jpg?mtime=1324455868" width="844" height="299" /></a></div>

<p>Under Audit can select the audit you have just created. If you have multiple audits all of them will show up, however if you choose one with a specification already assigned, then it will throw an error and warn you.</p>

<p>You can assign multiple audit actions, or audit action groups to one specification however for this exercise we will only use database_change_group to track database changes.After creating the audit the same steps should be followed to enable the specification.</p>

<p><em>Note: It is the default behaviour of Management Studio to create the specifications as well as the audits in an offline state.</em></p>

<p>So now that both the audit and the specification is in place, I made a few changes to a database and now we can look into the file using the following code:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb1955'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb1955','cb27331'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb1955" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #00AF00;">--returns all the columns for the file</span></li><li style="" class="li2"><span style="color: #0000FF;">SELECT</span> * <span style="color: #0000FF;">FROM</span> <span style="color: #00AF00;">fn_get_audit_file</span> <span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'E:\SQLAuditing\SQLAudit_DBChanges*.sqlaudit'</span>,<span style="color: #0000FF;">DEFAULT</span>,<span style="color: #0000FF;">DEFAULT</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #00AF00;">--Returns specific items to aid in analysing the audit file</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">SELECT</span> &nbsp;event_time ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; action_id ,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; succeeded ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; session_id ,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; server_principal_name ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; server_instance_name ,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; database_name ,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">statement</span><span style="color: #808080;">&#93;</span> ,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; audit_file_offset</li><li style="" class="li1"><span style="color: #0000FF;">FROM</span> &nbsp; &nbsp;<span style="color: #00AF00;">fn_get_audit_file</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'E:\SQLAuditing\SQLAudit_DBChanges*.sqlaudit'</span>,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">DEFAULT</span>, <span style="color: #0000FF;">DEFAULT</span><span style="color: #808080;">&#41;</span></li></ol></div><div id="cb27331" style="display: none; color: red;"></div></div></div>

<p><em>Note: All the files will be appended with a guid, there for it is easier to use the name and then a wildcard which is * to make it easier to load the file and to read the code.</em></p>

<p>The output of my test looks like this:</p>

<div class="image_block"><a href="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/ServerSpec/FailedResults.jpg?mtime=1324455860"><img alt="" src="http://blogs.lessthandot.com/media/users/sqlarcher/AuditBlog/ServerSpec/FailedResults.jpg?mtime=1324455860" width="1081" height="117" /></a></div>

<p>This is a quick specification to monitor for failed logins using the Server Audit Specification and to demonstrate how to do it. There is more information for the different action groups to use with the server audit specification <a href="http://msdn.microsoft.com/en-us/library/cc280663.aspx">here</a>.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-creating-a">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auditing-creating-a#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1558</wfw:commentRss>
		</item>
				<item>
			<title>SQL Server Audits: Introduction</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-audits-introduction</link>
			<pubDate>Wed, 21 Dec 2011 05:38:00 +0000</pubDate>			<dc:creator>SQLArcher</dc:creator>
			<category domain="main">Database Administration</category>
<category domain="alt">Microsoft SQL Server Admin</category>			<guid isPermaLink="false">1557@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Previously DBA&#039;s and in some cases even developers had to write custom triggers or set up various profiler traces to monitor what was happening in their SQL Server instances. When measures like this were left to the junior staff joining the company, it held potential disastrous complications in various forms ranging from bad performance due to the overhead or storage issues when traces are not monitored and archived. Some of these issues could take hours to resolve when the steps taken to audit the system is not documented and the root cause obscured in the form of witty triggers firing relentlessly.&lt;/p&gt;

&lt;p&gt;Then came SQL Server 2008... One of the numerous &quot;enhancements&quot; or features introduced in SQL Server 2008 are the Audit Specifications. The new component is built on top of the extended events feature, and there for provides a lightweight auditing mechanism.&lt;/p&gt;

&lt;p&gt;In this series which will continue over the next few days, I will cover some of the basics to set up auditing such as requirements, use cases, and some general audits that will poke their heads out in the  environment. &lt;/p&gt;

&lt;p&gt;To start the series off, let&#039;s look at the components that makes up the auditing feature.&lt;/p&gt;

&lt;p&gt;Both the target and server specification can be found under the instance security list, and the database level specification can be found under the security lists for the various individual databases.&lt;/p&gt;

&lt;p&gt;The three main components that make up the auditing feature is;&lt;/p&gt;

&lt;h3&gt;Server Audit Specification&lt;/h3&gt;
&lt;p&gt;This specification is specifically aimed at events on an instance level which includes login attempts, DBCC commands, backup and restores, and other instance level events.&lt;/p&gt;

&lt;h3&gt;Database Audit Specification&lt;/h3&gt;
&lt;p&gt;This specification is aimed at events related to all database level actions, like T-SQL statements, stored procedure executions, object modifications in terms of schema changes, etc.&lt;/p&gt;

&lt;h3&gt;Targets&lt;/h3&gt;
&lt;p&gt;The new auditing mechanism supports three targets; file, security log, and application log. This determines where your audit records end up as well as some additional actions as to what SQL Server should do when certain conditions are met i.e. shut down SQL when a failed login attempt occurs.&lt;/p&gt;

&lt;p&gt;When using a file target, the ACL should be set up to allow only the required accounts access, the SQL Service account, person or group that will act as the administrators which in both cases will require READ/WRITE to the directory.&lt;/p&gt;

&lt;p&gt;The application log is less secure as it can be read by anyone who successfully authenticates on the server. There for it is recommended to use the security log when writing to the event log.&lt;/p&gt;

&lt;p&gt;To log the events to the security log, the &lt;span class=&quot;MT_under&quot;&gt;generate security audits policy&lt;/span&gt; needs to be granted to the SQL Server service account. A detailed process can be found &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/cc645889.aspx&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the following posts we will cover creating a basic audit specifications on both server and database levels. We will also look at how to manage the audits, as well as some additional analysis we can do with the information that is captured.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-audits-introduction&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Previously DBA's and in some cases even developers had to write custom triggers or set up various profiler traces to monitor what was happening in their SQL Server instances. When measures like this were left to the junior staff joining the company, it held potential disastrous complications in various forms ranging from bad performance due to the overhead or storage issues when traces are not monitored and archived. Some of these issues could take hours to resolve when the steps taken to audit the system is not documented and the root cause obscured in the form of witty triggers firing relentlessly.</p>

<p>Then came SQL Server 2008... One of the numerous "enhancements" or features introduced in SQL Server 2008 are the Audit Specifications. The new component is built on top of the extended events feature, and there for provides a lightweight auditing mechanism.</p>

<p>In this series which will continue over the next few days, I will cover some of the basics to set up auditing such as requirements, use cases, and some general audits that will poke their heads out in the  environment. </p>

<p>To start the series off, let's look at the components that makes up the auditing feature.</p>

<p>Both the target and server specification can be found under the instance security list, and the database level specification can be found under the security lists for the various individual databases.</p>

<p>The three main components that make up the auditing feature is;</p>

<h3>Server Audit Specification</h3>
<p>This specification is specifically aimed at events on an instance level which includes login attempts, DBCC commands, backup and restores, and other instance level events.</p>

<h3>Database Audit Specification</h3>
<p>This specification is aimed at events related to all database level actions, like T-SQL statements, stored procedure executions, object modifications in terms of schema changes, etc.</p>

<h3>Targets</h3>
<p>The new auditing mechanism supports three targets; file, security log, and application log. This determines where your audit records end up as well as some additional actions as to what SQL Server should do when certain conditions are met i.e. shut down SQL when a failed login attempt occurs.</p>

<p>When using a file target, the ACL should be set up to allow only the required accounts access, the SQL Service account, person or group that will act as the administrators which in both cases will require READ/WRITE to the directory.</p>

<p>The application log is less secure as it can be read by anyone who successfully authenticates on the server. There for it is recommended to use the security log when writing to the event log.</p>

<p>To log the events to the security log, the <span class="MT_under">generate security audits policy</span> needs to be granted to the SQL Server service account. A detailed process can be found <a href="http://msdn.microsoft.com/en-us/library/cc645889.aspx">here</a>.</p>

<p>In the following posts we will cover creating a basic audit specifications on both server and database levels. We will also look at how to manage the audits, as well as some additional analysis we can do with the information that is captured.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-audits-introduction">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-audits-introduction#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1557</wfw:commentRss>
		</item>
				<item>
			<title>SQL Server Denali Feature Packs</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sql-server-denali-feature-packs</link>
			<pubDate>Thu, 21 Jul 2011 14:36:00 +0000</pubDate>			<dc:creator>SQLArcher</dc:creator>
			<category domain="main">Data Modelling &amp; Design</category>
<category domain="alt">Microsoft SQL Server Admin</category>			<guid isPermaLink="false">1345@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;So by this time all of you should know that SQL Server &quot;Denali&quot; CTP 3 is out and about.&lt;/p&gt;

&lt;p&gt;For all of you(like me) who rushed to download and install it, there is a little secret. There are a few feature packs as well available to accompany your new installation and Visual Studio 2010(with SP 1).&lt;/p&gt;

&lt;p&gt;All the feature packs can be found &lt;a href=&quot;http://www.microsoft.com/download/en/details.aspx?id=26726&quot;&gt;here&lt;/a&gt;, including the alluding Books On Line which doesn&#039;t force you to connect to the internet version.&lt;/p&gt;

&lt;p&gt;Happy exploring and testing the new features.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sql-server-denali-feature-packs&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>So by this time all of you should know that SQL Server "Denali" CTP 3 is out and about.</p>

<p>For all of you(like me) who rushed to download and install it, there is a little secret. There are a few feature packs as well available to accompany your new installation and Visual Studio 2010(with SP 1).</p>

<p>All the feature packs can be found <a href="http://www.microsoft.com/download/en/details.aspx?id=26726">here</a>, including the alluding Books On Line which doesn't force you to connect to the internet version.</p>

<p>Happy exploring and testing the new features.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sql-server-denali-feature-packs">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sql-server-denali-feature-packs#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1345</wfw:commentRss>
		</item>
				<item>
			<title>Transaction Log: VLF's, Auto Growth and Performance</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/transaction-log-vlf-s-auto</link>
			<pubDate>Wed, 11 May 2011 09:03:00 +0000</pubDate>			<dc:creator>SQLArcher</dc:creator>
			<category domain="alt">Data Modelling &amp; Design</category>
<category domain="main">Microsoft SQL Server Admin</category>
<category domain="alt">Microsoft SQL Server</category>			<guid isPermaLink="false">1248@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Recently I presented at SQLSat 83 about VLF&#039;s and their performance impact on our databases. I decided to write this post as well for everyone who couldn&#039;t make it all the way to Johannesburg, South Africa.&lt;/p&gt;
&lt;p&gt;To provide a bit of history on the subject, I was tasked in March to evaluate a server which came under severe strain. After investigating the numerous issues from insufficient memory to slow internal disk space ( raised alerts in SQL log, and monitoring some of the buffer and memory counters in perfmon), I came to the intermediate solution to redo the log allocation.&lt;/p&gt;
&lt;p&gt;&amp;#160;&lt;/p&gt;
&lt;h2&gt;T-Log Overview:&lt;/h2&gt;
&lt;p&gt;Before we dive into the virtual log files, let&#039;s take a quick recap on what the T-Log is and how it works.&lt;/p&gt;
&lt;h3&gt;What is a Transaction Log and How Does it Work?&lt;/h3&gt;
&lt;p&gt;A transaction log is a record of all modifications made to a database, including system stored proc&#039;s, DDL statements, begin/end of a transaction, extent allocation/deallocations, etc. It is also the key roleplayer in restoring back ups, point-in-time recovery(FULL recovery model only) and transactional and merge replication. A log record for each modification is made in the log cache, and a LSN(log sequence number) is assigned to the modification.&lt;/p&gt;
&lt;p&gt;&amp;#160;&lt;/p&gt;
&lt;p&gt;SQL Server uses a read-ahead log model; this means that any data modifications are not immediately made to the data directly, rather a copy of the data residing in memory. Let&#039;s see how it works:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;SQL will first check the buffer cache if the required data page is there.&lt;/li&gt;
&lt;li&gt;If the data page is not found, then it will make a copy to the buffer cache.&lt;/li&gt;
&lt;li&gt;The data modification is applied to data page in the buffer cache.&lt;/li&gt;
&lt;li&gt;When the data page is written to disk, it is called a &lt;em&gt;page flush&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;The log will write all of the modified data pages to disk via the lazy writer when;&lt;ol&gt;
&lt;li&gt;A CHECKPOINT occurs.&lt;/li&gt;
&lt;li&gt;A COMMIT TRAN occurs.&lt;/li&gt;
&lt;li&gt;Transactional/Merge replicated transactions are transfered to the subscriber.&lt;/li&gt;
&lt;li&gt;Space is required for new data pages.&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Note, when a modification is written directly to disk without a log record being created; that modification cannot be rolled back until the next FULL backup is made.&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The use of the read-ahead log model ensures that the ACID principals are not broken and to ensure redundancy, integrity as well as a recoverable database when you are using FULL recovery model.&lt;/p&gt;
&lt;h2&gt;Virtual Log Files:&lt;/h2&gt;
&lt;p&gt;VLF&#039;s is what makes up the transaction log internally. We can see the VLF&#039;s with the following command:&lt;/p&gt;
&lt;p&gt;DBCC LOGINFO(DB_Name)&lt;/p&gt;
&lt;p&gt;You should then see something similiar to this:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;/media/users/sqlarcher/vlf.jpg?mtime=1305048340&quot;&gt;&lt;img title=&quot;VLF Screen&quot; src=&quot;/media/users/sqlarcher/vlf.jpg?mtime=1305048340&quot; alt=&quot;&quot; width=&quot;593&quot; height=&quot;368&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Columns of note are:&lt;/p&gt;
&lt;p&gt;FileSize - file size in bytes.&lt;/p&gt;
&lt;p&gt;Status - 0 not in use, 2 in use.&lt;/p&gt;
&lt;p&gt;CreateLSN - Log Sequence Number.&lt;/p&gt;
&lt;p&gt;When looking to optimize the T-Log we are looking actually looking to allocate the right number, and correctly sized VLF&#039;s. When VLF&#039;s are created, either by autogrow or a manual grow; a certain number of VLF&#039;s are allocated according to the size.&lt;/p&gt;
&lt;p&gt;&amp;lt; 64MB will create 4 VLF&#039;s&lt;/p&gt;
&lt;p&gt;&amp;gt;= 64MB &amp;lt; 1GB will create 8 VLF&#039;s&lt;/p&gt;
&lt;p&gt;and &amp;gt; than 1GB will create 16 VLF&#039;s.&lt;/p&gt;
&lt;p&gt;This is by design due to the algorithms used within the SQL Engine. If you create a new database, and pre create the log file with 16GB, then you will have 16 VLF&#039;s with a size of 1GB each.&lt;/p&gt;
&lt;p&gt;In some cases you do not want to pre create the log file with a size that might make your VLF&#039;s unmanageable like a 64GB log. A 64GB log will create 16 VLF&#039;s with a size of 4GB. This can be problematic because a VLF is only cleared after it has been filled, but the same account to having VLF&#039;s which is too small.&lt;/p&gt;
&lt;p&gt;&quot;Why don&#039;t you create multiple log files to ensure that transactions are split?&quot; is a popular question, with a simple answer. The T-Log works sequentially and in a round robin fashion. The only benefit in adding multiple log files is redundancy, in case the drive or RAID configuration fails for the particular log file.&lt;/p&gt;
&lt;p&gt;&amp;#160;&lt;/p&gt;
&lt;h3&gt;The Test&lt;/h3&gt;
&lt;p&gt;I created a 50,000 row data set, for two databases using Data Generator from Red-Gate Software.&lt;/p&gt;
&lt;p&gt;Below is the schema for the table:&lt;/p&gt;
&lt;p&gt;&amp;#160;&lt;/p&gt;
&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb20772&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;TABLE&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;dbo&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;vlftab&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;ID&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;IDENTITY&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NOT NULL, &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;comment&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;8000&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NOT NULL, &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;Name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NOT NULL, &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;surname&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; NOT NULL, &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;DoB&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NOT NULL, &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;acc&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NOT NULL, &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;joindate&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;datetime&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#93;&lt;/span&gt; NOT NULL&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb61944&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;I then used three basic statements to test how long it takes to complete:&lt;/p&gt;
&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb29993&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;update&lt;/span&gt; presentation_fast..&lt;span style=&quot;color: #202020;&quot;&gt;vlftab&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;set&lt;/span&gt; comment = &lt;span style=&quot;color: #FF00FF;&quot;&gt;upper&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;comment&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;,&lt;br /&gt;name = &lt;span style=&quot;color: #FF00FF;&quot;&gt;upper&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;name&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;,&lt;br /&gt;surname = &lt;span style=&quot;color: #FF00FF;&quot;&gt;upper&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;surname&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;insert&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;into&lt;/span&gt; Presentation_fast..&lt;span style=&quot;color: #202020;&quot;&gt;vlftab&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;select&lt;/span&gt; comment, Name, surname, DoB, acc, joindate &lt;span style=&quot;color: #0000FF;&quot;&gt;from&lt;/span&gt; Presentation_Fast..&lt;span style=&quot;color: #202020;&quot;&gt;vlftab_source&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;delete&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;from&lt;/span&gt; Presentation_slow..&lt;span style=&quot;color: #202020;&quot;&gt;vlftab&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb75672&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Following company policy, I created for the SlowDB a log file which is 30% of the data size. This resulted in a log file which is 75MB. I manually grew the log in increments of 15MB, this resulted in 20 VLF&#039;s each with a size of 3.75MB. The second database, using the exact same data had a 8GB log with 16VLF&#039;s each sized 512MB.&lt;/p&gt;
&lt;p&gt;The results of the queries are as follows:&lt;/p&gt;
&lt;table style=&quot;border-color: #000000; border-width: 1px; width: 359px; height: 104px;&quot; border=&quot;1&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;SlowDB&lt;/td&gt;
&lt;td&gt;FastDB&lt;/td&gt;
&lt;td&gt;Improvement&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Insert(ms)&lt;/td&gt;
&lt;td&gt;13177&lt;/td&gt;
&lt;td&gt;6431&lt;/td&gt;
&lt;td&gt;205%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Update(ms)&lt;/td&gt;
&lt;td&gt;42558&lt;/td&gt;
&lt;td&gt;17837&lt;/td&gt;
&lt;td&gt;239%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delete(ms)&lt;/td&gt;
&lt;td&gt;13380&lt;/td&gt;
&lt;td&gt;6711&lt;/td&gt;
&lt;td&gt;199%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;It&#039;s quite shocking to see how something like this can affect a database, and the impact it can have on business. IF the log is allocated correctly, then it shouldn&#039;t auto grow which in some cases can cause that incorrectly sized VLF&#039;s are created, which could hamper performance.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Optimizing the transaction log escapes most of us when it goes further than the best RAID configs, or SSD&#039;s. But on systems without these configurations this can often be the solution to poor performing databases when every other avenue have been explored.&lt;/p&gt;
&lt;p&gt;For systems, to properly allocate the log file; is testing. A good tool I found for this is &lt;a href=&quot;http://www.sqlstress.com&quot;&gt;SQLStress&lt;/a&gt; as it can simulate different workloads and it&#039;s flexible.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/transaction-log-vlf-s-auto&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Recently I presented at SQLSat 83 about VLF's and their performance impact on our databases. I decided to write this post as well for everyone who couldn't make it all the way to Johannesburg, South Africa.</p>
<p>To provide a bit of history on the subject, I was tasked in March to evaluate a server which came under severe strain. After investigating the numerous issues from insufficient memory to slow internal disk space ( raised alerts in SQL log, and monitoring some of the buffer and memory counters in perfmon), I came to the intermediate solution to redo the log allocation.</p>
<p>&#160;</p>
<h2>T-Log Overview:</h2>
<p>Before we dive into the virtual log files, let's take a quick recap on what the T-Log is and how it works.</p>
<h3>What is a Transaction Log and How Does it Work?</h3>
<p>A transaction log is a record of all modifications made to a database, including system stored proc's, DDL statements, begin/end of a transaction, extent allocation/deallocations, etc. It is also the key roleplayer in restoring back ups, point-in-time recovery(FULL recovery model only) and transactional and merge replication. A log record for each modification is made in the log cache, and a LSN(log sequence number) is assigned to the modification.</p>
<p>&#160;</p>
<p>SQL Server uses a read-ahead log model; this means that any data modifications are not immediately made to the data directly, rather a copy of the data residing in memory. Let's see how it works:</p>
<ol>
<li>SQL will first check the buffer cache if the required data page is there.</li>
<li>If the data page is not found, then it will make a copy to the buffer cache.</li>
<li>The data modification is applied to data page in the buffer cache.</li>
<li>When the data page is written to disk, it is called a <em>page flush</em>.</li>
<li>The log will write all of the modified data pages to disk via the lazy writer when;<ol>
<li>A CHECKPOINT occurs.</li>
<li>A COMMIT TRAN occurs.</li>
<li>Transactional/Merge replicated transactions are transfered to the subscriber.</li>
<li>Space is required for new data pages.</li>
</ol></li>
<li><em>Note, when a modification is written directly to disk without a log record being created; that modification cannot be rolled back until the next FULL backup is made.</em></li>
</ol>
<p>The use of the read-ahead log model ensures that the ACID principals are not broken and to ensure redundancy, integrity as well as a recoverable database when you are using FULL recovery model.</p>
<h2>Virtual Log Files:</h2>
<p>VLF's is what makes up the transaction log internally. We can see the VLF's with the following command:</p>
<p>DBCC LOGINFO(DB_Name)</p>
<p>You should then see something similiar to this:</p>
<p><a href="http://blogs.lessthandot.com/media/users/sqlarcher/vlf.jpg?mtime=1305048340"><img title="VLF Screen" src="http://blogs.lessthandot.com/media/users/sqlarcher/vlf.jpg?mtime=1305048340" alt="" width="593" height="368" /></a></p>
<p>Columns of note are:</p>
<p>FileSize - file size in bytes.</p>
<p>Status - 0 not in use, 2 in use.</p>
<p>CreateLSN - Log Sequence Number.</p>
<p>When looking to optimize the T-Log we are looking actually looking to allocate the right number, and correctly sized VLF's. When VLF's are created, either by autogrow or a manual grow; a certain number of VLF's are allocated according to the size.</p>
<p>&lt; 64MB will create 4 VLF's</p>
<p>&gt;= 64MB &lt; 1GB will create 8 VLF's</p>
<p>and &gt; than 1GB will create 16 VLF's.</p>
<p>This is by design due to the algorithms used within the SQL Engine. If you create a new database, and pre create the log file with 16GB, then you will have 16 VLF's with a size of 1GB each.</p>
<p>In some cases you do not want to pre create the log file with a size that might make your VLF's unmanageable like a 64GB log. A 64GB log will create 16 VLF's with a size of 4GB. This can be problematic because a VLF is only cleared after it has been filled, but the same account to having VLF's which is too small.</p>
<p>"Why don't you create multiple log files to ensure that transactions are split?" is a popular question, with a simple answer. The T-Log works sequentially and in a round robin fashion. The only benefit in adding multiple log files is redundancy, in case the drive or RAID configuration fails for the particular log file.</p>
<p>&#160;</p>
<h3>The Test</h3>
<p>I created a 50,000 row data set, for two databases using Data Generator from Red-Gate Software.</p>
<p>Below is the schema for the table:</p>
<p>&#160;</p>
<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb3364'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb3364','cb18389'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb3364" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>vlftab<span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span> <span style="color: #808080;">&#91;</span>ID<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">int</span><span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">IDENTITY</span><span style="color: #808080;">&#40;</span><span style="color: #000;">1</span>,<span style="color: #000;">1</span><span style="color: #808080;">&#41;</span> NOT NULL, <span style="color: #808080;">&#91;</span>comment<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">8000</span><span style="color: #808080;">&#41;</span> NOT NULL, <span style="color: #808080;">&#91;</span>Name<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">20</span><span style="color: #808080;">&#41;</span> NOT NULL, <span style="color: #808080;">&#91;</span>surname<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">varchar</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#40;</span><span style="color: #000;">40</span><span style="color: #808080;">&#41;</span> NOT NULL, <span style="color: #808080;">&#91;</span>DoB<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">date</span><span style="color: #808080;">&#93;</span> NOT NULL, <span style="color: #808080;">&#91;</span>acc<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">int</span><span style="color: #808080;">&#93;</span> NOT NULL, <span style="color: #808080;">&#91;</span>joindate<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">datetime</span><span style="color: #808080;">&#93;</span> NOT NULL<span style="color: #808080;">&#41;</span></li></ol></div><div id="cb18389" style="display: none; color: red;"></div></div></div>
<p>I then used three basic statements to test how long it takes to complete:</p>
<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb52326'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb52326','cb90820'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb52326" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">update</span> presentation_fast..<span style="color: #202020;">vlftab</span> <span style="color: #0000FF;">set</span> comment = <span style="color: #FF00FF;">upper</span><span style="color: #808080;">&#40;</span>comment<span style="color: #808080;">&#41;</span>,</li><li style="" class="li2">name = <span style="color: #FF00FF;">upper</span> <span style="color: #808080;">&#40;</span>name<span style="color: #808080;">&#41;</span>,</li><li style="" class="li1">surname = <span style="color: #FF00FF;">upper</span><span style="color: #808080;">&#40;</span>surname<span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">insert</span> <span style="color: #0000FF;">into</span> Presentation_fast..<span style="color: #202020;">vlftab</span> <span style="color: #0000FF;">select</span> comment, Name, surname, DoB, acc, joindate <span style="color: #0000FF;">from</span> Presentation_Fast..<span style="color: #202020;">vlftab_source</span>;</li><li style="" class="li1"><span style="color: #0000FF;">delete</span> <span style="color: #0000FF;">from</span> Presentation_slow..<span style="color: #202020;">vlftab</span></li></ol></div><div id="cb90820" style="display: none; color: red;"></div></div></div>
<p>Following company policy, I created for the SlowDB a log file which is 30% of the data size. This resulted in a log file which is 75MB. I manually grew the log in increments of 15MB, this resulted in 20 VLF's each with a size of 3.75MB. The second database, using the exact same data had a 8GB log with 16VLF's each sized 512MB.</p>
<p>The results of the queries are as follows:</p>
<table style="border-color: #000000; border-width: 1px; width: 359px; height: 104px;" border="1">
<tbody>
<tr>
<td></td>
<td>SlowDB</td>
<td>FastDB</td>
<td>Improvement</td>
</tr>
<tr>
<td>Insert(ms)</td>
<td>13177</td>
<td>6431</td>
<td>205%</td>
</tr>
<tr>
<td>Update(ms)</td>
<td>42558</td>
<td>17837</td>
<td>239%</td>
</tr>
<tr>
<td>Delete(ms)</td>
<td>13380</td>
<td>6711</td>
<td>199%</td>
</tr>
</tbody>
</table>
<p>It's quite shocking to see how something like this can affect a database, and the impact it can have on business. IF the log is allocated correctly, then it shouldn't auto grow which in some cases can cause that incorrectly sized VLF's are created, which could hamper performance.</p>
<h3>Conclusion</h3>
<p>Optimizing the transaction log escapes most of us when it goes further than the best RAID configs, or SSD's. But on systems without these configurations this can often be the solution to poor performing databases when every other avenue have been explored.</p>
<p>For systems, to properly allocate the log file; is testing. A good tool I found for this is <a href="http://www.sqlstress.com">SQLStress</a> as it can simulate different workloads and it's flexible.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/transaction-log-vlf-s-auto">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/MSSQLServerAdmin/transaction-log-vlf-s-auto#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1248</wfw:commentRss>
		</item>
			</channel>
</rss>
