 




<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SQL Server with Mr. Denny &#187; SQL Server 2008 R2</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/sql-server/tag/sql-server-2008-r2/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/sql-server</link>
	<description></description>
	<lastBuildDate>Fri, 17 May 2013 17:04:01 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Using Event Viewer Logging for SSIS Performance Trouble Shooting</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/using-event-viewer-logging-for-ssis-performance-trouble-shooting/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/using-event-viewer-logging-for-ssis-performance-trouble-shooting/#comments</comments>
		<pubDate>Wed, 27 Mar 2013 14:00:51 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[BIDS]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=2131</guid>
		<description><![CDATA[So while working with a client recently I was going some performance tuning on SSIS for them.  While SSIS isn&#8217;t exactly my normal workload, the problem wasn&#8217;t really in SSIS, but just normal SQL Statements being called from SSIS. While attacking this problem, the first thing that I did was look into the SSIS package [...]]]></description>
				<content:encoded><![CDATA[<p>So while working with a client recently I was going some performance tuning on SSIS for them.  While SSIS isn&#8217;t exactly my normal workload, the problem wasn&#8217;t really in SSIS, but just normal SQL Statements being called from SSIS.</p>
<p>While attacking this problem, the first thing that I did was look into the SSIS package and see what I had gotten myself into.  There were hundreds of objects within SSIS, most of them T-SQL Scripts of Data Pump Tasks.  So simply going through them one by one wasn&#8217;t going to be all that helpful.  The client didn&#8217;t have any logging to SQL Server or to a text file setup, but they did have the SSIS package setup to log to the Windows event log.</p>
<p>Opening the Application log greated me with one event for the start of each task, and one for the completion of each task.  Not exactly the most useful information ever, but better than nothing, so I&#8217;ll take what I can get.  The first thing that I did was export the Application Event log to a CSV file and download it to my desktop so that I could do the processing on my local machine.  The CSV file has a few hundred thousand lines, so I needed to figure out what I had via scripting.  The first problem that I had was that for each SSIS event there were multiple lines within the csv when opened in Excel which you can see below.</p>
<p><img class="alignnone" src="http://mrdenny.com/wp-content/uploads/2012/07/excel.jpg" alt="" width="755" height="179" /></p>
<p>Thankfully this made the rows pretty unique looking, so an Excel Macro was able to clean this up pretty easily.  Before I got started I added some column headers into the excel sheet.  The default columns from Event Viewer are Date, Time, Source, Severity, Category, EventID, User, Computer, Description.  This covered columns A through I.  After that I put columns J through P as being Operator, SourceName, SourceID, Execution, StartTime, EndTime and DataCode as these are the specific items that SSIS is logging that you can see above.  Then it was time to bust out a little VBA and flatten out all this data.  The macro shown below looped through the data and flattened everything out so that all the data was on a single line.  Then is went through and removed all the white lines.  This macro took about 3 hours to run.</p>
<p><code>Sub CleanUpData()<br />
Dim Row As Long<br />
Dim DataRow As Long<br />
Row = 32768<br />
Do While Range("A" &amp; Row).Value = ""<br />
If Range("B" &amp; Row).Value = "" Then<br />
DataRow = Row<br />
Range("A" &amp; Row).Select<br />
Else<br />
If Left(Range("A" &amp; Row).Value, 4) = " Mes" Then<br />
Range("A" &amp; Row).Value = ""<br />
End If<br />
If Left(Range("A" &amp; Row).Value, 4) = " Ope" Then<br />
Range("J" &amp; DataRow).Value = Range("A" &amp; Row).Value<br />
Range("A" &amp; Row).Value = ""<br />
End If<br />
If Left(Range("A" &amp; Row).Value, 9) = " Source N" Then<br />
Range("K" &amp; DataRow).Value = Range("A" &amp; Row).Value<br />
Range("A" &amp; Row).Value = ""<br />
End If<br />
If Left(Range("A" &amp; Row).Value, 10) = " Source ID" Then<br />
Range("L" &amp; DataRow).Value = Range("A" &amp; Row).Value<br />
Range("A" &amp; Row).Value = ""<br />
End If<br />
If Left(Range("A" &amp; Row).Value, 4) = " Exe" Then<br />
Range("M" &amp; DataRow).Value = Range("A" &amp; Row).Value<br />
Range("A" &amp; Row).Value = ""<br />
End If<br />
If Left(Range("A" &amp; Row).Value, 4) = " Sta" Then<br />
Range("N" &amp; DataRow).Value = Range("A" &amp; Row).Value<br />
Range("A" &amp; Row).Value = ""<br />
End If<br />
If Left(Range("A" &amp; Row).Value, 4) = " End" Then<br />
Range("O" &amp; DataRow).Value = Range("A" &amp; Row).Value<br />
Range("A" &amp; Row).Value = ""<br />
End If<br />
If Left(Range("A" &amp; Row).Value, 4) = " Dat" Then<br />
Range("P" &amp; DataRow).Value = Range("A" &amp; Row).Value<br />
Range("A" &amp; Row).Value = ""<br />
End If<br />
End If<br />
Row = Row + 1<br />
Loop</code></p>
<p>Do While Row 2<br />
If Range(&#8220;A&#8221; &amp; Row).Value = &#8220;&#8221; Then<br />
Range(Row &amp; &#8220;:&#8221; &amp; Row).Select<br />
Selection.Delete<br />
End If<br />
Row = Row &#8211; 1<br />
Loop<br />
End Sub</p>
<p>Once that was done I needed to set the start times for each event on the same line as the end time for each event. That way I wasn&#8217;t scrolling through looking for stuff while trying to do my data analysis. This I was also able to do with a little Macro. In this case I started on row 14 as that was the first entry that had SSIS data. You may need to change the EndRow=14 line to what ever line your data starts on. This puts the start time and the end time into Columns R and S, but only on the line which is the OnPostExecute line.</p>
<p><code>Sub FindRunTimes()<br />
Dim EndRow As Long<br />
Dim StartRow As Long<br />
Dim SourceName As String<br />
EndRow = 14<br />
Do While Range("A" &amp; EndRow).Value = ""<br />
If Range("I" &amp; EndRow).Value = " Event Name: OnPostExecute" Then<br />
StartRow = EndRow + 1<br />
Do Until Range("K" &amp; EndRow).Value = Range("K" &amp; StartRow).Value And Range("I" &amp; StartRow).Value = " Event Name: OnPreExecute"<br />
If Range("I" &amp; StartRow).Value = "" Then<br />
MsgBox "Ran out of rows to process for ending row " &amp; EndRow<br />
Exit Sub<br />
End If<br />
StartRow = StartRow + 1<br />
Loop<br />
Range("S" &amp; EndRow).Value = Range("B" &amp; EndRow).Value<br />
Range("R" &amp; EndRow).Value = Range("B" &amp; StartRow).Value<br />
'Range("T" &amp; EndRow).Value = DateDiff("mi", Range("A" &amp; StartRow).Value &amp; " " &amp; Range("B" &amp; StartRow).Value, Range("A" &amp; EndRow).Value &amp; " " &amp; Range("B" &amp; EndRow).Value)<br />
Range("R" &amp; EndRow).Select<br />
End If<br />
EndRow = EndRow + 1<br />
Loop<br />
End Sub</code></p>
<p>Once that Macro was finished I needed to figure out which of the statements was taking to long to run. Putting a formula into the column Q marked the rows that I needed to look into a little more. In this case I was using anything with a run time of 20 minutes or longer as needing to be looked at.</p>
<p><code>=IF(HOUR(R595)=HOUR(S595)*60+MINUTE(S595),"", "X"), IF(HOUR(R595)*60+MINUTE(R595)+19&gt;=HOUR(S595)*60+MINUTE(S595)+1440,"", "X"))</code></p>
<p>Once that formula was in there all the rows that were SSIS objects that took a long time to run had an X next to them. Now I still needed to ignore the rows which were containers, but those were pretty easy to figure out from the names of the objects as most of them had container in them (in the SourceName column which was column K of my Worksheet). At this point I was able to move back to the SSIS package and start digging through the package finding the objects which had long runtimes and getting those looked at.</p>
<p>The whole reason I went through this process instead of just adding logging to the SSIS package was for a few different reasons.</p>
<ul>
<li>I didn&#8217;t want to make ANY changes to production if I didn&#8217;t have to. This SSIS package loads a production data warehouse which the business uses to run their company, so making changes to it wasn&#8217;t something I wanted to try.</li>
<li>If I had simply put logging into place I would have had to have waited another day to being looking at the problems as the ETL process only runs once a day.</li>
<li>The SSIS package takes 8+ hours to run, so sitting around waiting for it to run wasn&#8217;t exactly the best use of my time, or the clients money.</li>
</ul>
<p>If you get stuck in this same sort of problem, hopefully this approach will help you out.<br />
Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/using-event-viewer-logging-for-ssis-performance-trouble-shooting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deleting LOB Data and Shrinking the Database</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/deleting-lob-data-and-shrinking-the-database/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/deleting-lob-data-and-shrinking-the-database/#comments</comments>
		<pubDate>Wed, 13 Mar 2013 14:00:52 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[Andre Kamman]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[DBCC PAGE]]></category>
		<category><![CDATA[Mladen Prajdić]]></category>
		<category><![CDATA[Paul Randal]]></category>
		<category><![CDATA[SQL Saturday]]></category>
		<category><![CDATA[SQL Saturday 194]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[System Objects]]></category>
		<category><![CDATA[Tables]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=2564</guid>
		<description><![CDATA[While attending SQL Saturday 194 in Exeter over in England one of the attendees came to Mladen Prajdić, Andre Kamman and myself with an interesting problem.  She had a database table which was about 200 Gigs in size which she wanted to delete about half of the data from the table.  The catch was that the [...]]]></description>
				<content:encoded><![CDATA[<p>While attending <a href="http://www.sqlsaturday.com/194/eventhome.aspx">SQL Saturday 194</a> in Exeter over in England one of the attendees came to Mladen Prajdić, Andre Kamman and myself with an interesting problem.  She had a database table which was about 200 Gigs in size which she wanted to delete about half of the data from the table.  The catch was that the database table was full of LOB data where the rows were very large, with an average LOB data size of over a meg.  She also needed to shrink the database after the database was deleted so that she could reclaim the space from the database.  Oh and all this had to be done on SQL Server 2005 Standard Edition. (Everything here applies to SQL Server up through SQL Server 2012 as well.)</p>
<p>Deleting the data from the database is the easy part, a simple delete loop will handle that nicely.  The problem is when you delete rows from a table which contains LOB data the LOB pages aren&#8217;t cleared when they are deallocated.  We can see this by running the following code.</p>
<p><code>CREATE DATABASE Lobtest<br />
GO<br />
use Lobtest<br />
GO<br />
CREATE TABLE t1 (c1 int IDENTITY(1,1) PRIMARY KEY, c2 ntext)<br />
GO<br />
INSERT INTO T1 (c2) VALUES (replicate('a', 20000))<br />
GO<br />
DBCC IND ('LobTest', 't1', 1)<br />
GO<br />
DBCC TRACEON(5201, -1)<br />
GO<br />
DELETE FROM t1<br />
GO<br />
DBCC IND ('LobTest', 't1', 1)<br />
GO<br />
DECLARE @dbid as int = db_id('Lobtest')<br />
DBCC PAGE (@dbid, 1, 231, 3)<br />
GO</code></p>
<p>You can see that page 231 is a LOB page which is allocated to the table t1. When you look at the actual page using DBCC PAGE after the row has been deleted we can see that there is data in the page, and that the page header shows that the page is still allocated to the table t1. This can be seen by looking in the header of the page for the header value labeled &#8220;Metadata: ObjectId = 245575913&#8243;.</p>
<p>When you go to shrink the database the SQL Server engine will get to the LOB pages and it will need to figure out if the LOB row is a part of a row which still exists or not. In order to do this SQL Server will need to scan through the pages which make up the table looking for any rows which reference the page it is trying to delete.</p>
<p>When doing shrinks after deleing large amounts of LOB data SQL Server will generate large amounts of IO while figuring this out and the shrink operation will take an extremely long time. (Paul Randle talks more about <a href="http://www.sqlskills.com/blogs/paul/why-lob-data-makes-shrink-run-slooooowly-t-sql-tuesday-006/">it here</a>.)</p>
<p>So the question that this person at SQL Saturday had was, how can I reclaim the space from my database within a reasonable time.</p>
<p>The solution that we came up with was actually pretty simple.  Do the database deletion as normal.  Then backup and restore the database.  Then do the shrink, followed by rebuilding the clustered indexes in order to fix the fragmentation issue which the shrink will introduce.</p>
<p>This works for a pretty simple reason, because the PFS page shows that the LOB page isn&#8217;t allocated even though the page is full of data (you can verify this by looking at page 1 in file 1 in the sample database created by the script above).  When the database engine backups up the database the database engine looks at the PFS pages to figure out which pages to back up.  Because the PFS pages show that the pages are empty the database engine doesn&#8217;t bother to backup the pages, so when the pages are restored they are restored as blank pages.  This means that after the restore the shrink operation can run without an issue.</p>
<p>In the case of this application there was a maintenance window which could be taken advantage of which would allow the backup and the restore to happen.</p>
<p>Another option which we came up with which would require less downtime involved using database mirroring.  By configuring database mirroring (which is initialized via a backup and restore process giving us the same basic approach) and then failing over to the mirror we would end up in the same position.  We could then shrink the database without issue (probably pausing database mirroring so that we didn&#8217;t have to wait for the second server to process the shrink in real time) and then fail back the database to the original server.</p>
<p>As geeky as it was, Mladen, Andre and I had a great time figuring this out, and the attendee had a great time watching us go through all the possible options as we excluded them one by one.  And most importantly she got her problem solved.</p>
<p>So if you end up in this situation here&#8217;s a solution that will help you shrink the database so that you can reclaim the space that the LOB data pages are taking up without having to wait forever.</p>
<p>Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/deleting-lob-data-and-shrinking-the-database/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQL Saturday 177 Slide Deck</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/sql-saturday-177-slide-deck/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/sql-saturday-177-slide-deck/#comments</comments>
		<pubDate>Mon, 25 Feb 2013 23:44:34 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[SQL Saturday]]></category>
		<category><![CDATA[SQL Saturday 177]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>
		<category><![CDATA[SQL Server 2012]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=2553</guid>
		<description><![CDATA[This last weekend I had the privilege of speaking at SQL Saturday 177 in Mountain View, CA.  One of the great things about this SQL Saturday is that in some ways it is an extension of the MVP Summit as for the second year in a row (that I know of) this SQL Saturday has been [...]]]></description>
				<content:encoded><![CDATA[<p>This last weekend I had the privilege of speaking at SQL Saturday 177 in Mountain View, CA.  One of the great things about this SQL Saturday is that in some ways it is an extension of the MVP Summit as for the second year in a row (that I know of) this SQL Saturday has been scheduled the weekend after the MVP summit.  This means that they are able to attack a large number of MVPs from all over the country (and hopefully next year the world) as they all stop by on their way home.  This gives us MVPs a couple of extra days of hanging out and catching up and it gives the attendees the chance to see some speakers that they might not normally be able to get access to.</p>
<p>I gave one presentation this year, and it was a session of table partitioning.  The slide deck has been uploaded to the SQL Saturday site as has the sample code.  You can download it from the <a href="http://www.sqlsaturday.com/viewsession.aspx?sat=177&amp;sessionid=13266">session page for my session</a>.</p>
<p>I hope that everyone liked the session, and I hope to see everyone at a future SQL Saturday.</p>
<p>Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/sql-saturday-177-slide-deck/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cleaning Up Reporting Services Snapshots</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/cleaning-up-reporting-services-snapshots/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/cleaning-up-reporting-services-snapshots/#comments</comments>
		<pubDate>Wed, 20 Feb 2013 14:00:08 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=2452</guid>
		<description><![CDATA[If you&#8217;ve been running a SQL Server Reporting Services machine for a long time you may have noticed that your ReportServerTempDB database has filled up quite large over the years with lots of crap.  And it&#8217;s just kept going.  This is because sometimes SQL Server Reporting Services may be keeping more Snapshot data than it [...]]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;ve been running a SQL Server Reporting Services machine for a long time you may have noticed that your ReportServerTempDB database has filled up quite large over the years with lots of crap.  And it&#8217;s just kept going.  This is because sometimes SQL Server Reporting Services may be keeping more Snapshot data than it is supposed to (or maybe it has old stuff from before you limited how much crap it could keep.</p>
<p>In the case of one SSRS instance I ran across recently there were over 40k expired snapshots sitting in the ReportServerTempDB database.  Microsoft does include a stored procedure to get rid of these snapshots, but it only works on a single snapshot at a time, so you&#8217;ll need to call the stored procedure in a loop to clean up the extra crap.  This script worked nicely for me.</p>
<p><code>USE [ReportServer]<br />
GO<br />
DECLARE @return_value int,<br />
@SnapshotsCleaned int = 1,<br />
@ChunksCleaned int,<br />
@TempSnapshotID uniqueidentifier<br />
while @SnapshotsCleaned &lt;&gt; 0<br />
EXEC @return_value = [dbo].[CleanBrokenSnapshots]<br />
@Machine = @@SERVERNAME,<br />
@SnapshotsCleaned = @SnapshotsCleaned OUTPUT,<br />
@ChunksCleaned = @ChunksCleaned OUTPUT,<br />
@TempSnapshotID = @TempSnapshotID OUTPUT<br />
GO</code></p>
<p>You&#8217;ll notice that I&#8217;m simply setting the @SnapshotsCleaned value to 1 then running the procedure in a loop until that variable comes back as 0. That variable will only ever come back as 0, 1 or 2 (based on the SQL 2008 R2 version of Reporting Services) but the input parameter is INT so the variable matches that.</p>
<p>In any case, hopefully this helps you clean up your SQL Server Reporting Services ReportServerTempDB databases.</p>
<p>Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/cleaning-up-reporting-services-snapshots/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross Database Chaining</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/cross-database-chaining/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/cross-database-chaining/#comments</comments>
		<pubDate>Wed, 26 Dec 2012 14:00:05 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[Data Security]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Database security]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2000]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>
		<category><![CDATA[SQL Server 2012]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=1091</guid>
		<description><![CDATA[Cross database chaining in SQL Server is actually a fairly old feature, first introduced in SQL Server 2000 SP3.  However this feature isn&#8217;t often understood mostly because it isn&#8217;t often used. Database chaining is when permissions cascade from one object to another because they are used by the parent object.  The perfect example is a [...]]]></description>
				<content:encoded><![CDATA[<p>Cross database chaining in SQL Server is actually a fairly old feature, first introduced in SQL Server 2000 SP3.  However this feature isn&#8217;t often understood mostly because it isn&#8217;t often used.</p>
<p>Database chaining is when permissions cascade from one object to another because they are used by the parent object.  The perfect example is a stored procedure which accesses a table.  The user only needs rights to the parent object (the stored procedure) and the rights to access the table exist automatically because the stored procedure accesses the child object (the table).</p>
<p>Cross database chaining uses this exact same concept except that the parent object is in one database and the child object is in another database.  In order to use cross database chaining the feature needs to be enabled on both databases.  This is done by using the ALTER DATABASE statement as shown below on both databases.</p>
<blockquote><p>ALTER DATABASE A_Database SET DB_CHAINING ON</p></blockquote>
<p>Once this is done, the login which is mapped to the user within the database which has the parent object needs to be mapped to a login within the database which has the child object.  The user within the database which owns the child object doesn&#8217;t need any specific rights other than to be a member of the public role.  Once this is done the cross database permission chain will be made and the stored procedure (or other parent object such as a trigger or function) will begin working.</p>
<p>Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/cross-database-chaining/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backup Databases on Creation</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/backup-databases-on-creation/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/backup-databases-on-creation/#comments</comments>
		<pubDate>Sat, 17 Nov 2012 14:00:56 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[Backup & recovery]]></category>
		<category><![CDATA[BACKUP DATABASE]]></category>
		<category><![CDATA[CREATE TRIGGER]]></category>
		<category><![CDATA[Data Loss]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[DDL Trigger]]></category>
		<category><![CDATA[Recovery]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[T/SQL]]></category>
		<category><![CDATA[Transactions]]></category>
		<category><![CDATA[Trigger]]></category>
		<category><![CDATA[xp_create_subdir]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=2194</guid>
		<description><![CDATA[One of the companies which I work with has the occasion to create new databases when they do releases of their software.  Normally this isn&#8217;t a problem, except that they are setup to use maintenance plans to handle the backup and pruning of their transaction logs.  As all the new databases are created in the [...]]]></description>
				<content:encoded><![CDATA[<p>One of the companies which I work with has the occasion to create new databases when they do releases of their software.  Normally this isn&#8217;t a problem, except that they are setup to use maintenance plans to handle the backup and pruning of their transaction logs.  As all the new databases are created in the full recovery model this can end up causing some problems for them as within 12 minutes they start getting emails saying that the transaction log backup job has failed.  And these emails will keep coming in, possibly for hours until the full backup job kicks in later that night.</p>
<p>To solve this problem, I added a DDL trigger to the server which will cause the new database to be backed up as soon as the database is created.  The trigger itself is rather simple.  Most of the trigger is setting variables.  Then I make sure that the database isn&#8217;t a database snapshot, as database snapshots can&#8217;t be backed up.  If it isn&#8217;t a snapshot we continue with everything else.</p>
<p>Then I create a subfolder for the backups to be put into (the backups for each database go into their own folder, so as this is a new database the folder needs to be created).  Then I commit the transaction, as database backups can&#8217;t be taken within a transaction.  Then we do the actual database backup.  I then throw a message to the end user using the RAISERROR statement telling them that they can ignore the other error that they are going to get about the transaction being closed before the trigger was complete.  This is just an annoyance of my needing to commit the transaction before taking the backup.  Sure I could have setup a job which takes the backup and emails if there was a failure, but that just seems to complex for something so simple.  The code for my trigger is below.</p>
<blockquote><p>CREATE TRIGGER BackupNewDatabase<br />
ON ALL SERVER<br />
FOR CREATE_DATABASE<br />
AS<br />
declare @database sysname, @event_data XML = EVENTDATA(), @folder nvarchar(4000), @file nvarchar(4000)</p>
<p>SET @database = @event_data.value(&#8216;(/EVENT_INSTANCE/DatabaseName)[1]&#8216;, &#8216;sysname&#8217;)</p>
<p>set @folder = &#8216;X:\Backups\&#8217; + @database</p>
<p>set @file = @folder + &#8216;\&#8217; + @database + &#8216;.bak&#8217;</p>
<p>if exists (select * from sys.databases where name = @database and source_database_id is null)<br />
BEGIN<br />
EXEC master.dbo.xp_create_subdir @folder</p>
<p>COMMIT</p>
<p>BACKUP DATABASE @database to disk=@file</p>
<p>raiserror( &#8216;You can ignore the error message which says that the transaction ended within the trigger.&#8217;, 16,1)<br />
END<br />
GO</p></blockquote>
<p>Hopefully you find this solution helpful if you get into a situation like this,<br />
Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/backup-databases-on-creation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Second Edition of Securing SQL Server now longer available for pre-order. It&#8217;s Shipping! (repost)</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/second-edition-of-securing-sql-server-now-longer-available-for-pre-order-its-shipping-repost/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/second-edition-of-securing-sql-server-now-longer-available-for-pre-order-its-shipping-repost/#comments</comments>
		<pubDate>Thu, 09 Aug 2012 14:00:50 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Availability Groups]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[Data Loss]]></category>
		<category><![CDATA[Data Security]]></category>
		<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Database security]]></category>
		<category><![CDATA[Microsoft Windows]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2000]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[Storage]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=2236</guid>
		<description><![CDATA[In case you missed the blog post over on securingsqlserver.com, I wanted to repost it here&#8230; I&#8217;m afraid that I&#8217;ve got some bad news.  You can no longer pre-order Securing SQL Server 2nd Edition from Amazon. Instead you have to settle for ordering the book outright and having it shipped to you.  That&#8217;s right, no [...]]]></description>
				<content:encoded><![CDATA[<p>In case you missed the blog post over on <a href="http://www.securi">securingsqlserver.com</a>, I wanted to repost it here&#8230;</p>
<p>I&#8217;m afraid that I&#8217;ve got some bad news.  You can no longer pre-order <a href="http://www.amazon.com/gp/product/1597499471/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1597499471&amp;linkCode=as2&amp;tag=sesqse-20">Securing SQL Server 2nd Edition</a> from Amazon.</p>
<p>Instead you have to settle for <a href="http://www.amazon.com/gp/product/1597499471/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1597499471&amp;linkCode=as2&amp;tag=sesqse-20">ordering the book outright </a>and having it shipped to you.  That&#8217;s right, no more being a pre-order book, it&#8217;s published and available to be shipped directly to you.  Currently Amazon is selling the book at full price which is $49.95, but if you have Amazon Prime it is available for Amazon Prime shipping.  Because it is considered to be a text book you get a $5 Amazon MP3 Credit (what ever terms and conditions that Amazon chooses do apply).</p>
<p>This is a totally <a href="http://www.amazon.com/gp/product/1597499471/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1597499471&amp;linkCode=as2&amp;tag=sesqse-20">updated edition</a> of the book including all sorts of new information about security within SQL Server 2012.  I of course cover things like how to secure AlwaysOn Availability Groups, how to use user defined server roles, contained users, etc. I also dive into how to properly secure SQL Server Reporting Services and SQL Server Analysis Services so they can&#8217;t be used to access data that people shouldn&#8217;t have access to.</p>
<p>All in all this book is much larger with Amazon showing it at 408 pages compared to just 272 pages for the 1st edition.  If you find someone cheaper to purchase it make sure that you are in fact ordering the second edition.  The ISBN number is <a href="http://www.amazon.com/gp/product/1597499471/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1597499471&amp;linkCode=as2&amp;tag=sesqse-20">1597499471</a>.</p>
<p>I hope that you pick up a copy of the book and that it is useful for you in securing your SQL Server environment.</p>
<p>Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/second-edition-of-securing-sql-server-now-longer-available-for-pre-order-its-shipping-repost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Security Sessions at SQL PASS 2012</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/security-sessions-at-sql-pass-2012/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/security-sessions-at-sql-pass-2012/#comments</comments>
		<pubDate>Thu, 26 Jul 2012 14:00:34 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[Data Encryption]]></category>
		<category><![CDATA[Data Loss]]></category>
		<category><![CDATA[Data Security]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Database Design]]></category>
		<category><![CDATA[Database security]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SQL Injection]]></category>
		<category><![CDATA[SQL PASS]]></category>
		<category><![CDATA[SQL PASS 2012]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2000]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>
		<category><![CDATA[SQL Server 2012]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=2190</guid>
		<description><![CDATA[The SQL PASS session list for the SQL PASS 2012 Summit has been released.  This year there are 192 sessions being presented at the SQL PASS summit.  Last year at the 2011 summit there were only a couple of sessions on SQL Server Security.  This year there are 4 sessions.  While this appears to be a [...]]]></description>
				<content:encoded><![CDATA[<p>The <a href="http://www.sqlpass.org/summit/2012/Sessions/ConferenceSessions.aspx">SQL PASS session list</a> for the SQL PASS 2012 Summit has been released.  This year there are 192 sessions being presented at the SQL PASS summit.  Last year at the 2011 summit there were only a couple of sessions on SQL Server Security.  This year there are 4 sessions.  While this appears to be a bit better that before (if I remember correctly there were 3 last year), based on the number of large scale data breeches this year we need to be talking more about SQL Server security, and most importantly people need to actually listen.</p>
<p><a href="http://www.sqlpass.org/summit/2012/Sessions/SessionDetails.aspx?sid=2654">Where Should I Be Encrypting My Data</a> being presented by me</p>
<p><a href="http://www.sqlpass.org/summit/2012/Sessions/SessionDetails.aspx?sid=2886">SQL Server 2012 Security for Developers</a> being presented by Andreas Wolter</p>
<p><a href="http://www.sqlpass.org/summit/2012/Sessions/SessionDetails.aspx?sid=3361">The Evolution of Security in SQL Server 2012</a> being presented by Don Kiely</p>
<p><a href="http://www.sqlpass.org/summit/2012/Sessions/SessionDetails.aspx?sid=3251">SQL Injection: From Website to SQL Server</a> being presented by Mladen Prajdić</p>
<p>There are a couple of other sessions that mention <a href="http://www.sqlpass.org/summit/2012/Sessions/ConferenceSessions.aspx?k=security&amp;p=1&amp;preferred=false">security</a> in the abstract, but based on these abstracts I&#8217;m guessing that security won&#8217;t be mentioned very much during the actual sessions.</p>
<p>Denny</p>
<p>P.S. Don&#8217;t forget about my free <a href="http://itknowledgeexchange.techtarget.com/sql-server/sql-pass-2012-first-timers-webcast/">SQL PASS 2012 First Timer&#8217;s webcast</a> coming up on October 17th, 2012 at 1pm Pacific / 4pm Eastern.  You do need to <a href="https://docs.google.com/spreadsheet/viewform?formkey=dGNXcUw2Y29oZXF4V2NXSnlpRjAzcXc6MQ">sign up</a> for the session, which is FREE so get signed up.  Even if you have attended the SQL PASS summit before, this is worth it as there are some big changes in how PASS will be laid out at the convention center this year.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/security-sessions-at-sql-pass-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PBM, Replication and Stored Procedure Names</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/pbm-replication-and-stored-procedure-names/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/pbm-replication-and-stored-procedure-names/#comments</comments>
		<pubDate>Thu, 12 Jul 2012 14:00:20 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[Replication]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[System Objects]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=2113</guid>
		<description><![CDATA[One of the things that Policy Based management is really good at is making sure that people don&#8217;t create stored procedures that start with &#8220;sp_&#8221;.  However when the server that you are deploying the policies to is also being used for SQL Server replication this can get a little more complex seeing how all of [...]]]></description>
				<content:encoded><![CDATA[<p>One of the things that Policy Based management is really good at is making sure that people don&#8217;t create stored procedures that start with &#8220;sp_&#8221;.  However when the server that you are deploying the policies to is also being used for SQL Server replication this can get a little more complex seeing how all of the replication stored procedures start with &#8220;sp_&#8221; by default and they aren&#8217;t marked as system stored procedures.</p>
<p>I came across this problem when setting this up on a clients system.  The way that I was able to get around this was to setup Policy to evaluate against a condition which I had setup which filtered out the stored procedures that were used for SQL Server Replication.  I did this by setting up a condition, which I called &#8220;User Defined Stored Procedures&#8221; which had two values in the Expression.  The first was looking at the Schema field and excluding anything in the &#8220;sys&#8221; schema (which takes care of all the system objects), then looking at the Name field and excluding everything that matched &#8220;sp_MS%&#8221;.  You can see this condition below (click any of the images to enlarge).</p>
<p><a href="http://cdn.ttgtmedia.com/ITKE/uploads/blogs.dir/20/files/2012/06/userprocscondition1.jpg"><img class="alignnone size-thumbnail wp-image-2112" src="http://cdn.ttgtmedia.com/ITKE/uploads/blogs.dir/20/files/2012/06/userprocscondition1.jpg" alt="" width="128" height="93" /></a></p>
<p>Now to ensure that this only ran against the user databases I created another condition against the Database facet which looked at the IsSystemObject field and make sure that it was False, shown below.  That way I could put procedures like sp_whoisactive and sp_who3 into the master database and not have a problem with them.</p>
<p><a href="http://cdn.ttgtmedia.com/ITKE/uploads/blogs.dir/20/files/2012/06/userdatabases1.jpg"><img class="alignnone size-thumbnail wp-image-2111" src="http://cdn.ttgtmedia.com/ITKE/uploads/blogs.dir/20/files/2012/06/userdatabases1.jpg" alt="" width="128" height="93" /></a></p>
<p>The actual Check condition of the policy was setup easily enough, simply checking that the stored procedure name wasn&#8217;t like &#8220;sp%&#8221; as shown below.</p>
<p><a href="http://cdn.ttgtmedia.com/ITKE/uploads/blogs.dir/20/files/2012/06/storedprocname1.jpg"><img class="alignnone size-thumbnail wp-image-2110" src="http://cdn.ttgtmedia.com/ITKE/uploads/blogs.dir/20/files/2012/06/storedprocname1.jpg" alt="" width="128" height="93" /></a></p>
<p>Bringing this all together is the actual Policy which is configured with the check condition, and is configured to filter the objects being checked against the two other check conditions which helps to limit the amount of time that the policy takes to execute as shown below.  As this is a SQL Server 2008 R2 instance in this example I had to use a schedule to verify everything nightly, but that&#8217;ll do.</p>
<p><a href="http://cdn.ttgtmedia.com/ITKE/uploads/blogs.dir/20/files/2012/06/policy.jpg"><img class="alignnone size-thumbnail wp-image-2109" src="http://cdn.ttgtmedia.com/ITKE/uploads/blogs.dir/20/files/2012/06/policy.jpg" alt="" width="111" height="95" /></a></p>
<p>Hopefully if you run across this situation this will help you get everything setup faster that I was able to.</p>
<p>Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/pbm-replication-and-stored-procedure-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Time to Register for TechEd pre-cons</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/time-to-register-for-teched-pre-cons/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/time-to-register-for-teched-pre-cons/#comments</comments>
		<pubDate>Wed, 16 May 2012 21:16:25 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[Pre-Con]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[Tech Ed]]></category>
		<category><![CDATA[Tech Ed 2012]]></category>
		<category><![CDATA[Tech Ed Europe]]></category>
		<category><![CDATA[Tech Ed North America]]></category>
		<category><![CDATA[Tom LaRock]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/time-to-register-for-teched-pre-cons/</guid>
		<description><![CDATA[So Microsoft TechEd is quickly approaching. If you wanted to sign up for a pre-con there is still time, and plenty of space left available at both the North America and Europe TechEd pre-cons. These pre-cons are full day long sessions, being presented in this case by Tom LaRock and myself. In this session, learn [...]]]></description>
				<content:encoded><![CDATA[<p>So Microsoft TechEd is quickly approaching.  If you wanted to sign up for a pre-con there is still time, and plenty of space left available at both the North America and Europe TechEd pre-cons.  These pre-cons are full day long sessions, being presented in this case by Tom LaRock and myself.</p>
<blockquote><p>In this session, learn about SQL Server 2008 R2 and SQL Server 2012 performance tuning and optimization. Industry Experts Thomas LaRock and Denny Cherry guide you through tools and best practices for tuning queries and improving performance within Microsoft SQL Server. This session details real-life performance problems which have been gathered and tuned using industry standard best practices and real-world skills.</p></blockquote>
<p>You can sign up for North America <a href="http://northamerica.msteched.com/preconferenceseminars#fbid=a88PeWR_nCA">here</a>, or Europe <a href="http://europe.msteched.com/PreCons">here</a>.</p>
<p>I&#8217;ll see you in Orlando or Amsterdam,<br />
Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/time-to-register-for-teched-pre-cons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
