<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblogcasts.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">DavidWimbush</title><subtitle type="html">Observations of a SQL Server DBA and reporting &amp;amp; BI developer.</subtitle><id>http://sqlblogcasts.com/blogs/davidwimbush/atom.aspx</id><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/default.aspx" /><link rel="self" type="application/atom+xml" href="http://sqlblogcasts.com/blogs/davidwimbush/atom.aspx" /><generator uri="http://communityserver.org" version="3.1.20917.1142">Community Server</generator><updated>2009-09-18T10:20:00Z</updated><entry><title>Have you really fixed that problem?</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/archive/2010/03/18/have-you-really-fixed-that-problem.aspx" /><id>http://sqlblogcasts.com/blogs/davidwimbush/archive/2010/03/18/have-you-really-fixed-that-problem.aspx</id><published>2010-03-18T07:46:00Z</published><updated>2010-03-18T07:46:00Z</updated><content type="html">&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;The day before yesterday I saw&amp;nbsp;our main live server&amp;#39;s CPU go up to constantly 100% with just the occasional short drop to a lower level. The exact opposite of what you&amp;#39;d&amp;nbsp;want to see.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;We&amp;#39;re log shipping every 15 minutes and part of that involves calling WinRAR to compress the log backups before copying them over. (We&amp;#39;re on SQL2005 so there&amp;#39;s no native compression and we have bandwidth issues with the connection to our remote site.) I realised the log shipping jobs were taking about 10 minutes and that most of that was spent shipping a &amp;#39;live&amp;#39; reporting database that is completely rebuilt every 20 minutes. (I&amp;#39;m just trying to keep this stuff alive until I can improve it.)&amp;nbsp;We can rebuild this database in minutes if we have to fail over so I disabled log shipping of that database. The log shipping went down to less than&amp;nbsp;2 minutes and I went off to the SQL Social evening in London feeling quite pleased with myself. It was a great evening - fun, educational and thought-provoking. Thanks to Simon Sabin &amp;amp; co for laying that on, and thanks too to the guests for making the effort when they must have been pretty worn out after doing DevWeek all day first.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;The next morning I came down to earth with a bump: CPU still at 100%. WTF? I looked in the activity monitor but it was confusing because some sessions have been running for a long time so it&amp;#39;s not a good guide what&amp;#39;s using the CPU now. I tried the standard reports showing queries by CPU (average and total) but they only show the top 10 so they just show my big overnight archiving and data cleaning stuff. &lt;/font&gt;&lt;font size="2" face="verdana,geneva"&gt;But the Profiler showed it was four queries used by our new website usage tracking system. Four simple indexes later the CPU was back where it should be: about 20% with occasional short spikes.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;So the moral is: even when you&amp;#39;re convinced you&amp;#39;ve found the cause and fixed the problem, you HAVE to go back and confirm that the problem has gone.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;And, yes, I have checked the CPU again today and it&amp;#39;s still looking sweet.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=13305" width="1" height="1"&gt;</content><author><name>DavidWimbush</name><uri>http://sqlblogcasts.com/members/DavidWimbush.aspx</uri></author><category term="SQL Server 2005" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/SQL+Server+2005/default.aspx" /><category term="Tips and Tricks" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Tips+and+Tricks/default.aspx" /><category term="performance" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/performance/default.aspx" /></entry><entry><title>Finding rows that intersect with a date period</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/archive/2010/03/09/finding-rows-that-intersect-with-a-date-period.aspx" /><id>http://sqlblogcasts.com/blogs/davidwimbush/archive/2010/03/09/finding-rows-that-intersect-with-a-date-period.aspx</id><published>2010-03-09T19:40:00Z</published><updated>2010-03-09T19:40:00Z</updated><content type="html">&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;This one is mainly a personal reminder but I hope it helps somebody else too. Let&amp;#39;s say you have a table that covers something like currency exchange rates with columns for the start and end dates of the period each rate was applicable. Now you need to list the rates that applied during the year 2009. For some reason this always fazes me and I have to work it out with a diagram. So here&amp;#39;s the recipe so I never have to do that again:&lt;/font&gt;&lt;/p&gt;
&lt;div style="FONT-FAMILY:Consolas;BACKGROUND:white;COLOR:black;FONT-SIZE:8pt;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;select&amp;nbsp;&amp;nbsp;&lt;/span&gt;* &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;ExchangeRate&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;where&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;StartDate &amp;lt;= &lt;span style="COLOR:#a31515;"&gt;&amp;#39;31-DEC-2009&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;and &lt;/span&gt;EndDate &amp;gt;= &lt;span style="COLOR:#a31515;"&gt;&amp;#39;01-JAN-2009&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:#a31515;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;font size="2" face="verdana,geneva"&gt;That is all!&lt;/font&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=13240" width="1" height="1"&gt;</content><author><name>DavidWimbush</name><uri>http://sqlblogcasts.com/members/DavidWimbush.aspx</uri></author><category term="Tips and Tricks" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Tips+and+Tricks/default.aspx" /></entry><entry><title>Log shipping and shrinking transaction logs</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/archive/2010/03/04/log-shipping-and-shrinking-transaction-logs.aspx" /><id>http://sqlblogcasts.com/blogs/davidwimbush/archive/2010/03/04/log-shipping-and-shrinking-transaction-logs.aspx</id><published>2010-03-04T11:51:00Z</published><updated>2010-03-04T11:51:00Z</updated><content type="html">&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;I just solved a problem that had me worried for a bit. I&amp;#39;m log shipping from three primary servers to a single secondary server, and the transaction log disk on the secondary server was getting very full. I established that several primary databases had unused space that resulted from big, one-off updates so I could shrink their logs. But would this action be log shipped and applied to the secondary database too? I thought probably not. And, more importantly, would it break log shipping? &lt;/font&gt;&lt;font size="2" face="verdana,geneva"&gt;My secondary databases are in a Standby / Read Only state so I didn&amp;#39;t think I could shrink their logs. I RTFMd, Googled, and asked on a Q&amp;amp;A site (not the evil one) but was none the wiser.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;So I was facing a monumental round of shrink, full backup, full secondary restore and re-start log shipping&amp;nbsp;(which would leave us without a disaster recovery facility for the duration). Then I thought it might be worthwhile to take a non-essential database and just make &lt;em&gt;absolutely sure&lt;/em&gt; a log shrink on the primary wouldn&amp;#39;t ship over and occur on the secondary as well. So I did a DBCC SHRINKFILE and kept an eye on the secondary. Bingo! Log shipping didn&amp;#39;t blink and the log on the secondary shrank too.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;I just love it when something turns out even better than I dared to hope. (And I guess this highlights something I need to learn about what activities are logged.)&lt;/font&gt;&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=13203" width="1" height="1"&gt;</content><author><name>DavidWimbush</name><uri>http://sqlblogcasts.com/members/DavidWimbush.aspx</uri></author><category term="SQL Server 2005" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/SQL+Server+2005/default.aspx" /><category term="Log Shipping" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Log+Shipping/default.aspx" /></entry><entry><title>Cursor bad, set-based good</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/archive/2010/02/16/cursor-bad-set-based-good.aspx" /><id>http://sqlblogcasts.com/blogs/davidwimbush/archive/2010/02/16/cursor-bad-set-based-good.aspx</id><published>2010-02-16T07:40:00Z</published><updated>2010-02-16T07:40:00Z</updated><content type="html">&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;I just had another reminder, as if one was needed, that a cursor should be your&amp;nbsp;last resort to get something done.&amp;nbsp;I was looking to shave some time off my data warehouse build job and noticed a step that&amp;nbsp;looked like it was&amp;nbsp;taking a lot longer than I would expect. I found it was doing 12 cursors in a row on the same table. For each row in the source table it would try and insert into the target table and the insert was wrapped in a TRY...Catch to&amp;nbsp;suppress duplicate row insert errors and keep going.&amp;nbsp;Why? Because a few rogue cases had two rows instead of the one row they should have had. (For the record, I didn&amp;#39;t write this, I just inherited it.)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;I changed each cursor to a straight INSERT target-table SELECT&amp;nbsp;... FROM source-table&amp;nbsp;using a row_number&amp;nbsp;function to pick out just the first row for each case.&amp;nbsp;I thought it would go a fair bit faster. In fact, it went from 7 minutes to 15 seconds.&amp;nbsp;I had to check there was still the right number of rows in the target table!&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;I wish I had time to see how much of the overhead was the cursor and how much was the TRY...CATCH. I suspect each TRY...CATCH only makes a tiny difference but thousands of them will add up.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=13095" width="1" height="1"&gt;</content><author><name>DavidWimbush</name><uri>http://sqlblogcasts.com/members/DavidWimbush.aspx</uri></author><category term="performance" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/performance/default.aspx" /></entry><entry><title>Does this folder exist?</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/12/11/does-this-folder-exist.aspx" /><id>http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/12/11/does-this-folder-exist.aspx</id><published>2009-12-11T13:21:00Z</published><updated>2009-12-11T13:21:00Z</updated><content type="html">&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;Today I tripped over a problem that was new to me. I wanted to find out, in SQL, whether a folder existed in the file system. I knew about using xp_fileexist to check for existence of a file but what about a folder? Well, it doesn&amp;#39;t work on a folder name and there&amp;#39;s no sign of xp_folderexist. I finally found in a forum that you use xp_fileexist and pass in the imaginary file nul in that folder (eg. to check if the folder &amp;#39;C:\test&amp;#39; exists, check&amp;nbsp;if file &amp;#39;C:\test\nul&amp;#39; exists). There was no explanation but, according to &lt;a title="http://blogs.msdn.com/oldnewthing/archive/2003/10/22/55388.aspx" href="http://sqlblogcasts.com/controlpanel/blogs/Raymond%20Chen" target="_blank"&gt;Raymond Chen&lt;/a&gt; who knows a few things, NUL is a special, &amp;#39;magic&amp;#39; file name that goes back to DOS 1.0. So some days you learn an old new thing.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12716" width="1" height="1"&gt;</content><author><name>DavidWimbush</name><uri>http://sqlblogcasts.com/members/DavidWimbush.aspx</uri></author><category term="Tips and Tricks" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Tips+and+Tricks/default.aspx" /></entry><entry><title>Reporting security audit</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/12/01/reporting-security-audit.aspx" /><id>http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/12/01/reporting-security-audit.aspx</id><published>2009-12-01T22:06:00Z</published><updated>2009-12-01T22:06:00Z</updated><content type="html">&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;Today I set out to produce a list of who has access to each report so I could get this audited by the business management. I didn&amp;#39;t think it would take long. Download a couple of scripts, evaluate them, pick a good one, execute it, and on with the next job. After all, this is crucial stuff. There&amp;#39;s no point agonising over reducing users&amp;#39;s rights in the database engine to the minimum possible if you then go and give them access to reports that summarise all the data in a readable, saveable, printable form. Clearly then, security auditing of Reporting Services&amp;nbsp;must be a common practice. Or so I thought.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;Well, I found bits of the puzzle but I didn&amp;#39;t see anything packaged up and ready to go. I&amp;#39;m sure there are tools you can buy but I kind of resent paying serious money for a product that basically just queries my own data. I prefer source code where I can see what&amp;#39;s going on and learn something new.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;So I pulled the pieces together, solved a few problems myself&amp;nbsp;and came up with a stored proc that goes through Reporting&amp;#39;s security records for each report, resolves any domain groups recursively down to lists of users, and lists it all out. If you have a look through, you&amp;#39;ll see Reporting doesn&amp;#39;t make this security data easy to get hold of. Also, I had to add a caching mechanism for domain group membership because it took ages to query the domain that many times.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;Feel free to use the code, which you can download&amp;nbsp;&lt;a title="here" href="http://sqlblogcasts.com/blogs/davidwimbush/files/rpt_ITReportsSecurity.txt"&gt;here&lt;/a&gt;.&lt;/font&gt;&lt;/p&gt;
&lt;div style="FONT-FAMILY:Consolas;BACKGROUND:white;COLOR:black;FONT-SIZE:8pt;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;set quoted_identifier on&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;go&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;set &lt;/span&gt;ansi_nulls &lt;span style="COLOR:blue;"&gt;on&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;go&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;if exists &lt;/span&gt;(&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;select &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;from &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dbo.sysobjects &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;where &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; id = &lt;span style="COLOR:blue;"&gt;object_id&lt;/span&gt;(N&lt;span style="COLOR:#a31515;"&gt;&amp;#39;dbo.rpt_ITReportsSecurity&amp;#39;&lt;/span&gt;) &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;and &lt;/span&gt;objectproperty(id, N&lt;span style="COLOR:#a31515;"&gt;&amp;#39;IsProcedure&amp;#39;&lt;/span&gt;) = 1&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;drop procedure &lt;/span&gt;dbo.rpt_ITReportsSecurity&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;go&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;create proc &lt;/span&gt;dbo.rpt_ITReportsSecurity&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;as&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;/*&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;----------------------------------------------------------------------&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;Version:&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.0&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;Date:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;01/12/2009&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;----------------------------------------------------------------------&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;*/&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;set nocount on&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;declare &lt;/span&gt;@FolderName&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; nvarchar(850)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , @ReportName&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; nvarchar(850)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , @ReportPath&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; nvarchar(850)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , @idoc&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , @xmlfile&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(8000)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , @GroupUserName&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(50)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , @Role&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(50)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , @GroupNoDomain&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(50)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , @i&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , @cmd&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; nvarchar(2000)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;create table &lt;/span&gt;#perms&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;(&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GroupUserName&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(50)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , Role&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(50)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;create table &lt;/span&gt;#allperms&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;(&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FolderName&amp;nbsp;&amp;nbsp;&amp;nbsp; nvarchar(850)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , ReportName&amp;nbsp;&amp;nbsp;&amp;nbsp; nvarchar(850)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , GroupUserName&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(50)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , [Role]&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(50)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;create table &lt;/span&gt;#temp_domaingroup &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;(&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [output] &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(8000)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;create table &lt;/span&gt;#group_member &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;(&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Group]&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(50)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , Member&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(100)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , [Role]&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(50)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;-- Loop through reports&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;declare &lt;/span&gt;report_cursor &lt;span style="COLOR:blue;"&gt;cursor&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;local &lt;/span&gt;forward_only &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;for &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;select&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;f.Name &lt;span style="COLOR:blue;"&gt;as &lt;/span&gt;Folder&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , r.Name &lt;span style="COLOR:blue;"&gt;as &lt;/span&gt;ReportName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , r.Path &lt;span style="COLOR:blue;"&gt;as &lt;/span&gt;ReportPath&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;from&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ReportServer.dbo.Catalog r &lt;span style="COLOR:blue;"&gt;with &lt;/span&gt;(&lt;span style="COLOR:blue;"&gt;nolock&lt;/span&gt;)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;inner join &lt;/span&gt;ReportServer.dbo.Catalog f &lt;span style="COLOR:blue;"&gt;with &lt;/span&gt;(&lt;span style="COLOR:blue;"&gt;nolock&lt;/span&gt;) &lt;span style="COLOR:blue;"&gt;on &lt;/span&gt;f.ItemID = r.ParentID&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;where&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;r.Type = 2 &lt;span style="COLOR:green;"&gt;-- Report&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;order by &lt;/span&gt;f.Name&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , r.Name&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;open &lt;/span&gt;report_cursor&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;fetch next from &lt;/span&gt;report_cursor &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;into &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @FolderName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; , @ReportName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; , @ReportPath&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;while &lt;/span&gt;@@fetch_status = 0&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;begin&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;-- Get the user/groups and their roles from the XML&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;truncate table &lt;/span&gt;#perms;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;set &lt;/span&gt;@xmlfile = (&lt;span style="COLOR:blue;"&gt;select&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;sd.XmlDescription&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;from&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ReportServer.dbo.Catalog c&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;inner join &lt;/span&gt;ReportServer.dbo.Policies p &lt;span style="COLOR:blue;"&gt;on &lt;/span&gt;p.PolicyID = c.PolicyID &lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;left join &lt;/span&gt;ReportServer.dbo.SecData sd &lt;span style="COLOR:blue;"&gt;on &lt;/span&gt;sd.PolicyID = p.PolicyID &lt;span style="COLOR:blue;"&gt;and &lt;/span&gt;AuthType = 1&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;where&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;c.Path = @ReportPath&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;and &lt;/span&gt;p.PolicyFlag = 0) &lt;span style="COLOR:green;"&gt;--as far as I can tell, this means not a system policy&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;exec &lt;/span&gt;sp_xml_preparedocument @idoc &lt;span style="COLOR:blue;"&gt;output&lt;/span&gt;, @xmlfile&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;insert&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#perms &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (GroupUserName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; , [Role])&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;select&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;GroupUsername&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; , Role&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;from&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;openxml&amp;nbsp;&amp;nbsp;&amp;nbsp; (@idoc, N&lt;span style="COLOR:#a31515;"&gt;&amp;#39;/Policies/Policy/Roles/Role&amp;#39;&lt;/span&gt;,2)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;with&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(GroupUsername &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(50) &lt;span style="COLOR:#a31515;"&gt;&amp;#39;../../GroupUserName&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; , Role &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(50) &lt;span style="COLOR:#a31515;"&gt;&amp;#39;./Name&amp;#39;&lt;/span&gt;)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;exec &lt;/span&gt;sp_xml_removedocument @idoc;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;-- Loop through users/groups&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;declare &lt;/span&gt;group_cursor &lt;span style="COLOR:blue;"&gt;cursor&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;local &lt;/span&gt;forward_only &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;for &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;select&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;GroupUserName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; , [Role]&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;from&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#perms&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;where&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;GroupUserName &amp;lt;&amp;gt; &lt;span style="COLOR:#a31515;"&gt;&amp;#39;BUILTIN\Administrators&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;and &lt;/span&gt;[Role] &amp;lt;&amp;gt; &lt;span style="COLOR:#a31515;"&gt;&amp;#39;View Folders Role&amp;#39;&lt;/span&gt;;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;open &lt;/span&gt;group_cursor&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;fetch next from &lt;/span&gt;group_cursor &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;into &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @GroupUserName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; , @Role&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;while &lt;/span&gt;@@fetch_status = 0&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;begin&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:green;"&gt;-- Strip the domain off the user/group&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;set &lt;/span&gt;@GroupNoDomain = @GroupUserName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;set &lt;/span&gt;@i = &lt;span style="COLOR:blue;"&gt;charindex&lt;/span&gt;(&lt;span style="COLOR:#a31515;"&gt;&amp;#39;\&amp;#39;&lt;/span&gt;, @GroupNoDomain)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;if &lt;/span&gt;@i &amp;gt; 0&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;begin&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;set &lt;/span&gt;@GroupNoDomain = &lt;span style="COLOR:blue;"&gt;substring&lt;/span&gt;(@GroupNoDomain, @i + 1, 100)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;end&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:green;"&gt;-- Users in the groups are cached so we only need to query the domain once for each group&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;if not exists &lt;/span&gt;(&lt;span style="COLOR:blue;"&gt;select &lt;/span&gt;1 &lt;span style="COLOR:blue;"&gt;from &lt;/span&gt;#group_member &lt;span style="COLOR:blue;"&gt;where &lt;/span&gt;[Group] = @GroupNoDomain)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;begin&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:green;"&gt;-- Query the domain&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;truncate table &lt;/span&gt;#temp_domaingroup;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;set &lt;/span&gt;@cmd = &lt;span style="COLOR:#a31515;"&gt;&amp;#39;dsquery group -name &amp;quot;&amp;#39; &lt;/span&gt;+ @GroupNoDomain + &lt;span style="COLOR:#a31515;"&gt;&amp;#39;&amp;quot; | dsget group -members -expand&amp;#39;&lt;/span&gt;;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;insert&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#temp_domaingroup &lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;exec &lt;/span&gt;xp_cmdshell @cmd;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;if exists &lt;/span&gt;(&lt;span style="COLOR:blue;"&gt;select &lt;/span&gt;1 &lt;span style="COLOR:blue;"&gt;from &lt;/span&gt;#temp_domaingroup &lt;span style="COLOR:blue;"&gt;where &lt;/span&gt;[output] &lt;span style="COLOR:blue;"&gt;like &lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;#39;dsget failed%&amp;#39;&lt;/span&gt;)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;begin&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:green;"&gt;-- It&amp;#39;s a user, not a group, so add it to the cache&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;insert&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#group_member&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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;&amp;nbsp; ([Group]&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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;&amp;nbsp; , Member&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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;&amp;nbsp; , [Role])&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;values&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(@GroupNoDomain&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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;&amp;nbsp; , @GroupUserName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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;&amp;nbsp; , @Role);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;end&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;else&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;begin&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:green;"&gt;-- Add the users in the group to the cache&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;insert&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#group_member&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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;&amp;nbsp; ([Group]&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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;&amp;nbsp; , Member&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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;&amp;nbsp; , [Role])&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;select&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;@GroupNoDomain&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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;&amp;nbsp; , &lt;span style="COLOR:blue;"&gt;substring&lt;/span&gt;(x.Member, 5, len(x.Member) - 4)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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;&amp;nbsp; , @Role&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;from&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;select&amp;nbsp;&amp;nbsp;&amp;nbsp; substring&lt;/span&gt;([output], 1, &lt;span style="COLOR:blue;"&gt;charindex&lt;/span&gt;(&lt;span style="COLOR:#a31515;"&gt;&amp;#39;,OU=&amp;#39;&lt;/span&gt;, [output], 1) - 1) &lt;span style="COLOR:blue;"&gt;as &lt;/span&gt;Member&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;from&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#temp_domaingroup &lt;/p&gt;
&lt;p style="MARGIN:0px;"&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;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;where&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[output] &lt;span style="COLOR:blue;"&gt;is not null&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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;&amp;nbsp; ) x;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;end&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;end&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:green;"&gt;-- Add the user or group users and their roles to the permissions list&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;insert&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#allperms&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; (FolderName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; , ReportName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; , GroupUserName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; , [Role])&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;select&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;@FolderName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; , @ReportName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; , Member&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; , [Role]&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;from&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#group_member&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;where&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[Group] = @GroupNoDomain;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:green;"&gt;-- Get the next cursor row&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;fetch next from &lt;/span&gt;group_cursor &lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;into &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @GroupUserName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; , @Role&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;end&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;close &lt;/span&gt;group_cursor&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;deallocate &lt;/span&gt;group_cursor&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;-- Get the next cursor row&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;fetch next from &lt;/span&gt;report_cursor &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;into &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @FolderName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; , @ReportName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; , @ReportPath&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;end&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;close &lt;/span&gt;report_cursor&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;deallocate &lt;/span&gt;report_cursor&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;select&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;*&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;from&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#allperms&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;order by &lt;/span&gt;ReportName;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;go&lt;/p&gt;&lt;/div&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12662" width="1" height="1"&gt;</content><author><name>DavidWimbush</name><uri>http://sqlblogcasts.com/members/DavidWimbush.aspx</uri></author><category term="SQL Server 2005" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/SQL+Server+2005/default.aspx" /><category term="Reporting Services" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Reporting+Services/default.aspx" /><category term="SQL Server 2008" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/SQL+Server+2008/default.aspx" /><category term="Security" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Security/default.aspx" /></entry><entry><title>A better way to arrange your query windows</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/11/28/a-better-way-to-arrange-your-query-windows.aspx" /><id>http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/11/28/a-better-way-to-arrange-your-query-windows.aspx</id><published>2009-11-28T19:37:00Z</published><updated>2009-11-28T19:37:00Z</updated><content type="html">&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;The developers of Management Studio and, before that, Query Analyzer have made a bit of a habit of building killer features and then hiding them in the small print of Books Online. Now &lt;em&gt;you&lt;/em&gt; may already know that SQL &lt;em&gt;&lt;strong&gt;2000&lt;/strong&gt;&lt;/em&gt; introduced a new way to arrange your query and result windows, but&amp;nbsp;&lt;em&gt;I&lt;/em&gt; only just found out about it. I think it&amp;#39;s great so, in case you blinked and missed it too, here&amp;#39;s how it works.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;Since the dawn of time you edited your query in a full window and, when you ran it, the results covered the bottom half of the query. You could use Ctrl+R to toggle the visibility of the results. When you think about it, it&amp;#39;s actually pretty clumsy. These are the only combinations you can see easily:&lt;/font&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;font size="2" face="verdana,geneva"&gt;half of the query and half the results&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;the whole query&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;er, that&amp;#39;s it&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;I was so used to it that I didn&amp;#39;t really notice. Until somebody showed me a much better way to do it.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;There&amp;#39;s an option under Query Results | SQL Server | Results to Grid called &lt;strong&gt;Display results in a separate tab&lt;/strong&gt;. If you tick this and its sub-option the behaviour gets much more usable. When you run the query the results fill the screen. You get a second row of tabs below the row of tabs for the query windows you&amp;#39;ve got open. This second row has&amp;nbsp;tabs for the query, results and messages and (optionally) things like the query plan.&amp;nbsp;It looks like this:&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;img border="0" alt="" src="http://sqlblogcasts.com/blogs/davidwimbush/blog_pics/querytabs.jpg" width="454" height="224" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;You can tab backwards and forwards between these tabs using F6 and Shift+F6 respectively. You can quickly toggle between the query and results and you can see both of them properly.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;You really should try this. Your muscle memory will protest but stick with it. I think you&amp;#39;ll find it was worth it.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12645" width="1" height="1"&gt;</content><author><name>DavidWimbush</name><uri>http://sqlblogcasts.com/members/DavidWimbush.aspx</uri></author><category term="Tips and Tricks Management Studio" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Tips+and+Tricks+Management+Studio/default.aspx" /></entry><entry><title>How to process a cube in a SQL Agent job</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/11/25/how-to-process-a-cube-in-a-sql-agent-job.aspx" /><id>http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/11/25/how-to-process-a-cube-in-a-sql-agent-job.aspx</id><published>2009-11-25T11:09:00Z</published><updated>2009-11-25T11:09:00Z</updated><content type="html">&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;It can be done but it&amp;#39;s not well documented and it&amp;#39;s complicated by the fact that you can&amp;#39;t easily get the result of the process. Unless you actively check and manually raise an error if there&amp;#39;s been a problem,&amp;nbsp;the job will report sucess no matter how screwed up the cube processing is. That part is all about the XML results that are output by the process.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;Here&amp;#39;s how I do it (and&amp;nbsp;I&amp;#39;d be very interested if you have any suggestions to improve it):&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;Connect to the Analysis Services server&amp;nbsp;in SQL Server Management Studio.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;Right click on the database and select Process.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;Configure all the options and then&amp;nbsp;use the Script button to grab the XML that defines the processing job. It will look something like this:&lt;/font&gt;&lt;/p&gt;
&lt;div style="FONT-FAMILY:Consolas;BACKGROUND:white;COLOR:black;FONT-SIZE:8pt;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Batch&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;xmlns&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt;http://schemas.microsoft.com/analysisservices/2003/engine&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;ErrorConfiguration&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;xmlns:xsd&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt;http://www.w3.org/2001/XMLSchema&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;xmlns:xsi&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;xmlns:ddl2&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt;http://schemas.microsoft.com/analysisservices/2003/engine/2&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;xmlns:ddl2_2&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt;http://schemas.microsoft.com/analysisservices/2003/engine/2/2&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;KeyErrorLimit&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;-1&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;KeyErrorLimit&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;KeyErrorLogFile&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;\\rep01\joblogs\ProcessASOnBI1KeyErrors.log&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;KeyErrorLogFile&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;KeyNotFound&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;ReportAndContinue&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;KeyNotFound&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;KeyErrorAction&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;ConvertToUnknown&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;KeyErrorAction&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;KeyErrorLimitAction&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;StopProcessing&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;KeyErrorLimitAction&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;KeyDuplicate&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;IgnoreError&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;KeyDuplicate&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;NullKeyConvertedToUnknown&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;IgnoreError&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;NullKeyConvertedToUnknown&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;NullKeyNotAllowed&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;ReportAndContinue&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;NullKeyNotAllowed&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;ErrorConfiguration&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Process&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;xmlns:xsd&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt;http://www.w3.org/2001/XMLSchema&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;xmlns:xsi&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;xmlns:ddl2&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt;http://schemas.microsoft.com/analysisservices/2003/engine/2&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;xmlns:ddl2_2&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt;http://schemas.microsoft.com/analysisservices/2003/engine/2/2&lt;/span&gt;&amp;quot;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Object&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;DatabaseID&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;BI1&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;DatabaseID&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Object&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Type&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;ProcessFull&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Type&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;WriteBackTableCreation&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;UseExisting&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;WriteBackTableCreation&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Process&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;Batch&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;Create a new SQL Agent job.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;Add a step to&amp;nbsp;get rid of any old output file(s). Change the step type to CmdExec and paste in this code, modifying the file name:&lt;/font&gt;&lt;/p&gt;&lt;font size="1"&gt;
&lt;p&gt;if exist &amp;quot;\\rep01\joblogs\ProcessASOnBI1Log.xml&amp;quot; (del &amp;quot;\\rep01\joblogs\ProcessASOnBI1Log.xml&amp;quot;)&lt;/p&gt;&lt;/font&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;Add a step for the processing. Change the step type to SQL Server Analysis Services Command and paste in the XML. Go to the Advanced page and give it an XML output file - with the same name you used in the previous step - to write its results to.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;Add a step to check the output XML file to see whether the process was successful. Change the step type to T-SQL and paste in this code:&lt;/font&gt;&lt;/p&gt;&lt;font size="2" face="Verdana"&gt;
&lt;div style="FONT-FAMILY:Consolas;BACKGROUND:white;COLOR:black;FONT-SIZE:8pt;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;-- Check the result files from the cubes&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;set nocount on&lt;/span&gt;;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;create table &lt;/span&gt;#File&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;(&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ResultFileName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(255)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;insert &lt;/span&gt;#File (ResultFileName) &lt;span style="COLOR:blue;"&gt;values &lt;/span&gt;(&lt;span style="COLOR:#a31515;"&gt;&amp;#39;\\rep01\joblogs\ProcessASOnBI1Log.xml&amp;#39;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;insert &lt;/span&gt;#File (ResultFileName) &lt;span style="COLOR:blue;"&gt;values &lt;/span&gt;(&lt;span style="COLOR:#a31515;"&gt;&amp;#39;\\rep01\joblogs\ProcessASOnBI2Log.xml&amp;#39;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;create table &lt;/span&gt;#FileContents &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;(&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LineNumber&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;int identity&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , LineContents&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nvarchar(4000)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;declare &lt;/span&gt;@FileContents&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nvarchar(4000)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , @NewLine&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;char&lt;/span&gt;(2)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , @FileName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(255)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , @CubesFailed&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;bit&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , @CmdLine&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(300)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;set &lt;/span&gt;@NewLine = &lt;span style="COLOR:blue;"&gt;char&lt;/span&gt;(13) + &lt;span style="COLOR:blue;"&gt;char&lt;/span&gt;(10);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;set &lt;/span&gt;@CubesFailed = 0;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;-- Loop through result files&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;declare &lt;/span&gt;file_cursor &lt;span style="COLOR:blue;"&gt;cursor&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;local &lt;/span&gt;forward_only &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;for &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ResultFileName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#File;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;open &lt;/span&gt;file_cursor&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;fetch next from &lt;/span&gt;file_cursor &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;into &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @FileName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;while &lt;/span&gt;@@fetch_status = 0&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;begin&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;set &lt;/span&gt;@CmdLine = &lt;span style="COLOR:#a31515;"&gt;&amp;#39;type &amp;#39; &lt;/span&gt;+ @FileName;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;insert &lt;/span&gt;#FileContents&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;exec &lt;/span&gt;master.dbo.xp_cmdshell @CmdLine;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;@FileContents = &lt;span style="COLOR:blue;"&gt;isnull&lt;/span&gt;(@FileContents, &lt;span style="COLOR:#a31515;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;) + @NewLine + &lt;span style="COLOR:blue;"&gt;isnull&lt;/span&gt;(LineContents, &lt;span style="COLOR:#a31515;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#FileContents;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;select &lt;/span&gt;@FileName;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;select &lt;/span&gt;@FileContents;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;set nocount off&lt;/span&gt;;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;if &lt;/span&gt;@FileContents &lt;span style="COLOR:blue;"&gt;like &lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;#39;%error%&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;begin&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;set &lt;/span&gt;@CubesFailed = 1&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;end&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;delete &lt;/span&gt;#FileContents;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:green;"&gt;-- Get the next cursor row&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;fetch next from &lt;/span&gt;file_cursor &lt;/p&gt;
&lt;p style="MARGIN:0px;"&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; &lt;span style="COLOR:blue;"&gt;into &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @FileName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;end&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;close &lt;/span&gt;file_cursor&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;deallocate &lt;/span&gt;file_cursor&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;drop table &lt;/span&gt;#FileContents;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;drop table &lt;/span&gt;#File;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;if &lt;/span&gt;@CubesFailed = 1&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;begin&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;raiserror&lt;/span&gt;(&lt;span style="COLOR:#a31515;"&gt;&amp;#39;Cubes failed to build.&amp;#39;&lt;/span&gt;, 16, 1)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;end&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/font&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;Modify it to add your own file name(s) into #File at the top. This step will raise an error if the processing failed. If you don&amp;#39;t do this, you won&amp;#39;t know whether the job has worked.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12603" width="1" height="1"&gt;</content><author><name>DavidWimbush</name><uri>http://sqlblogcasts.com/members/DavidWimbush.aspx</uri></author><category term="SQL Server 2005" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/SQL+Server+2005/default.aspx" /><category term="SQLAgent" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/SQLAgent/default.aspx" /><category term="Analysis Services" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Analysis+Services/default.aspx" /></entry><entry><title>Is this log backup file the next one to restore?</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/11/22/is-this-log-backup-file-the-next-one-to-restore.aspx" /><id>http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/11/22/is-this-log-backup-file-the-next-one-to-restore.aspx</id><published>2009-11-22T20:52:00Z</published><updated>2009-11-22T20:52:00Z</updated><content type="html">&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;When you restore from a&amp;nbsp;transaction log backup, SQL Server checks the file against the database and gives you an error if the file is not the next one in the sequence. I wanted to know how this works so I did some digging. Not much in Books Online that I could see so I did some practical investigation with some of my log shipping files.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;It looks like it compares&amp;nbsp;the last LSN in the backup file&amp;#39;s header with the last LSN in the database&amp;#39;s restore history. If the last LSN in the file is less than&amp;nbsp;the last LSN in the restore history, it indicates that the database already contains those transactions. Here&amp;#39;s some code that does it:&lt;/font&gt;&lt;/p&gt;
&lt;div style="FONT-FAMILY:Consolas;BACKGROUND:white;COLOR:black;FONT-SIZE:8pt;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;declare&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;@LastDBLSN&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;numeric&lt;/span&gt;(25,0)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; , @LastFileLSN&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;numeric&lt;/span&gt;(25,0)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--Get last LSN from database&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;select&amp;nbsp;&amp;nbsp;&amp;nbsp; top &lt;/span&gt;1 @LastDBLSN = bs.last_lsn&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;from&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;msdb.dbo.restorehistory rh &lt;span style="COLOR:blue;"&gt;with &lt;/span&gt;(&lt;span style="COLOR:blue;"&gt;nolock&lt;/span&gt;)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;left join &lt;/span&gt;msdb.dbo.backupset bs &lt;span style="COLOR:blue;"&gt;with &lt;/span&gt;(&lt;span style="COLOR:blue;"&gt;nolock&lt;/span&gt;) &lt;span style="COLOR:blue;"&gt;on &lt;/span&gt;bs.backup_set_id = rh.backup_set_id&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;where&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;rh.destination_database_name = @DBName&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;order by &lt;/span&gt;rh.restore_history_id &lt;span style="COLOR:blue;"&gt;desc&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--Get last LSN from backup file&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;declare &lt;/span&gt;@logbak &lt;span style="COLOR:blue;"&gt;table&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;(&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BackupName nvarchar(128)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , BackupDescription nvarchar(255)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , BackupType &lt;span style="COLOR:blue;"&gt;smallint&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , ExpirationDate &lt;span style="COLOR:blue;"&gt;datetime&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , Compressed &lt;span style="COLOR:blue;"&gt;tinyint&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , &lt;span style="COLOR:blue;"&gt;Position smallint&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , DeviceType &lt;span style="COLOR:blue;"&gt;tinyint&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , UserName nvarchar(128)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , ServerName nvarchar(128)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , DatabaseName nvarchar(128)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , DatabaseVersion &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , DatabaseCreationDate &lt;span style="COLOR:blue;"&gt;datetime&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , BackupSize &lt;span style="COLOR:blue;"&gt;numeric&lt;/span&gt;(20, 0)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , FirstLSN &lt;span style="COLOR:blue;"&gt;numeric&lt;/span&gt;(25, 0)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , LastLSN &lt;span style="COLOR:blue;"&gt;numeric&lt;/span&gt;(25,0)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , CheckpointLSN &lt;span style="COLOR:blue;"&gt;numeric&lt;/span&gt;(25,0)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , DatabaseBackupLSN &lt;span style="COLOR:blue;"&gt;numeric&lt;/span&gt;(25, 0)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , BackupStartDate &lt;span style="COLOR:blue;"&gt;datetime&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , BackupFinishDate &lt;span style="COLOR:blue;"&gt;datetime&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , SortOrder &lt;span style="COLOR:blue;"&gt;smallint&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , CodePage &lt;span style="COLOR:blue;"&gt;smallint&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , UnicodeLocaleId &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , UnicodeComparisonStyle &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , CompatibilityLevel &lt;span style="COLOR:blue;"&gt;tinyint&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , SoftwareVendorId &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , SoftwareVersionMajor &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , SoftwareVersionMinor &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , SoftwareVersionBuild &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , MachineName nvarchar(128)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , Flags &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , BindingID uniqueidentifier&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , RecoveryForkID uniqueidentifier&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , Collation nvarchar(128)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , FamilyGUID uniqueidentifier&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , HasBulkLoggedData &lt;span style="COLOR:blue;"&gt;bit&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , IsSnapshot &lt;span style="COLOR:blue;"&gt;bit&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , IsReadOnly &lt;span style="COLOR:blue;"&gt;bit&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , IsSingleUser &lt;span style="COLOR:blue;"&gt;bit&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , HasBackupChecksums &lt;span style="COLOR:blue;"&gt;bit&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , IsDamaged &lt;span style="COLOR:blue;"&gt;bit&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , BeginsLogChain &lt;span style="COLOR:blue;"&gt;bit&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , HasIncompleteMetaData &lt;span style="COLOR:blue;"&gt;bit&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , IsForceOffline &lt;span style="COLOR:blue;"&gt;bit&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , IsCopyOnly &lt;span style="COLOR:blue;"&gt;bit&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , FirstRecoveryForkID uniqueidentifier&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , ForkPointLSN &lt;span style="COLOR:blue;"&gt;numeric&lt;/span&gt;(25, 0) &lt;span style="COLOR:blue;"&gt;null&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , RecoveryModel nvarchar(60)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , DifferentialBaseLSN &lt;span style="COLOR:blue;"&gt;numeric&lt;/span&gt;(25, 0) &lt;span style="COLOR:blue;"&gt;null&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , DifferentialBaseGUID uniqueidentifier&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , BackupTypeDescription nvarchar(60)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , BackupSetGUID uniqueidentifier &lt;span style="COLOR:blue;"&gt;null&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;insert &lt;/span&gt;@logbak &lt;span style="COLOR:blue;"&gt;exec &lt;/span&gt;(&lt;span style="COLOR:#a31515;"&gt;&amp;#39;restore headeronly from disk = &amp;#39;&amp;#39;&amp;#39; &lt;/span&gt;+ @FileName + &lt;span style="COLOR:#a31515;"&gt;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;select &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @LastFileLSN = LastLSN&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;from&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;@logbak;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;-- Compare them&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;if &lt;/span&gt;@LastFileLSN &amp;lt; @LastDBLSN&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;begin&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;-- Already got these transactions&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;end&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;else&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;begin&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;-- Restore log&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;end&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12577" width="1" height="1"&gt;</content><author><name>DavidWimbush</name><uri>http://sqlblogcasts.com/members/DavidWimbush.aspx</uri></author><category term="Backup &amp;amp; Restore" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Backup+_2600_amp_3B00_+Restore/default.aspx" /></entry><entry><title>Idera discontinues SQLSafe Freeware Edition</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/11/10/idera-discontinues-sqlsafe-freeware-edition.aspx" /><id>http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/11/10/idera-discontinues-sqlsafe-freeware-edition.aspx</id><published>2009-11-10T10:58:00Z</published><updated>2009-11-10T10:58:00Z</updated><content type="html">&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;No longer available for download. Check it out here: &lt;a href="http://www.idera.com/Products/Free-Tools/SQL-safe-Freeware-Edition/"&gt;http://www.idera.com/Products/Free-Tools/SQL-safe-Freeware-Edition/&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;Bummer! I&amp;#39;m using this extensively. Now you have to choose between the Enterprise edition and the Lite Edition. The Lite Edition is $295 per instance, which is not quite as attractive a price as free. I suppose it was too good to last. Luckily, I just got the budget approved to upgrade to 2008 R2 Standard, which has native backup compression. Can&amp;#39;t wait!&lt;/font&gt;&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12501" width="1" height="1"&gt;</content><author><name>DavidWimbush</name><uri>http://sqlblogcasts.com/members/DavidWimbush.aspx</uri></author><category term="Backup &amp;amp; Restore" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Backup+_2600_amp_3B00_+Restore/default.aspx" /></entry><entry><title>Report Manager folder &amp; file security</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/11/02/report-manager-folder-amp-file-security.aspx" /><id>http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/11/02/report-manager-folder-amp-file-security.aspx</id><published>2009-11-02T14:40:00Z</published><updated>2009-11-02T14:40:00Z</updated><content type="html">&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;Just found the answer to something that has been irritating me slightly for ages: how to give a user access to a report without giving them access to all the other reports in the folder.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;We have folders that are based on the roles people perform in the company. We granted the appropriate domain groups access to their folders in the Browser role. That gives those people access to the reports in those folders because, by default, a report inherits its security from&amp;nbsp;its parent folder. This works great until the Sales Manager says, &amp;quot;Can you give Student Joe access to the Sales Stats report so he can do a special job for me?&amp;quot; This report is in the Management folder which also contains a load of sensitive reports that Student Joe cannot be allowed to see, so you can&amp;#39;t give him the Browser role on the folder. You can override the inherited security on the Sales Stats report by putting Student Joe in the Browser role at that level but he still can&amp;#39;t get to it in the Report Manager because he has no rights on the&amp;nbsp;Management folder. His only access is via a URL direct to the report.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;We thought we were stuck with this and had got used to it. After all, people could get to what they needed so there wasn&amp;#39;t much of a business case for sorting it out properly. But today I got another such request and the red mist siezed me. (Perhaps it&amp;#39;s the weather?) I couldn&amp;#39;t believe this was impossible. Surely they thought of this? And, thanks to the excellent &lt;a class="" title="Hitchhiker&amp;#39;s Guide to SQL Server 2000 Reporting Services" href="http://www.amazon.com/Hitchhikers-Guide-Server-Reporting-Services/dp/0321268288"&gt;Hitchhiker&amp;#39;s Guide to SQL Server Reporting Services&lt;/a&gt;, I discovered that they did. They just didn&amp;#39;t go out of their way to mention it.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;Here are the steps:&lt;/font&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;font face="Verdana" size="2"&gt;On the Home page, click on &lt;strong&gt;Site Settings&lt;/strong&gt;.&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;font face="verdana,geneva" size="2"&gt;Click on &lt;strong&gt;Configure item-level role definitions&lt;/strong&gt;.&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;font face="Verdana" size="2"&gt;Create a new role (say, View Folders Role) and assign it the &lt;strong&gt;View folders&lt;/strong&gt; task.&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;font face="Verdana" size="2"&gt;Now you can assign a user or group the &lt;strong&gt;View Folders Role&lt;/strong&gt; on a&amp;nbsp;folder and they will be able to navigate to the folder and there they will see any reports you have given them access to.&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Easy when you know how!&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12475" width="1" height="1"&gt;</content><author><name>DavidWimbush</name><uri>http://sqlblogcasts.com/members/DavidWimbush.aspx</uri></author><category term="SQL Server 2005" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/SQL+Server+2005/default.aspx" /><category term="Reporting Services" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Reporting+Services/default.aspx" /><category term="Tips and Tricks" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Tips+and+Tricks/default.aspx" /></entry><entry><title>Something to check for on your Disaster Recovery plan</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/10/12/something-to-check-for-on-your-disaster-recovery-plan.aspx" /><id>http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/10/12/something-to-check-for-on-your-disaster-recovery-plan.aspx</id><published>2009-10-12T07:46:00Z</published><updated>2009-10-12T07:46:00Z</updated><content type="html">&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;We just had something happen that caught us by surprise.&amp;nbsp;We were&amp;nbsp;log shipping to a remote warm&amp;nbsp;standby server. It was&amp;nbsp;all running smoothly and we were ready for anything. Then the remote server went down - right down. Looks like we might have to rebuild it. Meanwhile, I&amp;#39;ve got transaction log backups piling up and nowhere to ship them to. Without a standby server that&amp;#39;s on the same backup cycle as the live server we just don&amp;#39;t &lt;em&gt;have&lt;/em&gt; a DR plan that applies. Now I have to tell people I can&amp;#39;t do those urgent things I promised to deliver because I have to sort this out. And I thought it was hard enough getting buy-in for setting this up in the first place!&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;When we drew up our plan we did briefly consider what would happen in this scenario. We were&amp;nbsp;far too casual. We said to ourselves, &amp;quot;Well, we didn&amp;#39;t have this capability at all until now and we&amp;#39;ve never had a disaster so it won&amp;#39;t be such a problem to be without it again while we fix it. After all, you can only plan for so much and after that you just have to wing it.&amp;quot; Wrong answer! The last thing you want to be doing when things are all screwed up is to start improvising.&amp;nbsp;A standby server is just as likely to fail as&amp;nbsp;a live server, maybe even &lt;em&gt;more&lt;/em&gt; likely. After all, you keep a keen pro-active eye on your live servers - you &lt;em&gt;are&lt;/em&gt; doing that, right? - but it&amp;#39;s hard to justify spending too much time monitoring a&amp;nbsp;standby server. As long as the replication/mirroring/log-shipping&amp;nbsp;works, that&amp;#39;s fine. Wrong! A standby server is just as important and warrants&amp;nbsp;just as much&amp;nbsp;care and feeding.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;Don&amp;#39;t let this happen to you. What does your plan say about the standby going down? How does it affect your routine DR jobs etc. How will you get a standby server back again? Do you need to alert the business that you may need some budget? How will you re-synch it with your live server so you can resume normal operations again? Knowing in principle is not enough. Write it down. Test it. Know it will work.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12404" width="1" height="1"&gt;</content><author><name>DavidWimbush</name><uri>http://sqlblogcasts.com/members/DavidWimbush.aspx</uri></author><category term="Disaster Recovery" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Disaster+Recovery/default.aspx" /></entry><entry><title>More fun with SQL 2008 and Windows 7</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/10/09/more-fun-with-sql-2008-and-windows-7.aspx" /><id>http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/10/09/more-fun-with-sql-2008-and-windows-7.aspx</id><published>2009-10-09T07:21:00Z</published><updated>2009-10-09T07:21:00Z</updated><content type="html">&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;I&amp;#39;ve just got round to trying out Reporting Services on my laptop, having rebuilt it with Windows 7. I&amp;#39;m fairly comfortable with Reporting on XP but I&amp;#39;ve clearly got some reading to do because there was some baffling security weirdness that I never would have fixed without help. Once again, a great product is let down by stuff that you have to be pretty advanced to understand. With the installation problems I had and this one, if I was a newbie I would probably by now have written off SQL Server up as a pile of crap and started looking at a competitor&amp;#39;s product.&lt;/font&gt;&lt;/p&gt;&lt;font face="verdana,geneva" size="2"&gt;
&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;This is SQL 2008 Developer installed on Windows 7 Pro on a standalone laptop. I have no domain. I defaulted everything during installation: Report Server is in Native mode and the Reporting Services service is running under the Local System account. When I browsed to http://&amp;lt;machine-name&amp;gt;/Reports&amp;nbsp;it asked me for my login and password.&amp;nbsp;Odd. I thought it would default to Windows authentication and just let me in. Then, a&lt;/font&gt;lthough I&amp;#39;m a member of the local Administrators group in Windows, I couldn&amp;#39;t do anything in Report Manager. I could see the Home page but not the links to administer security etc. Only My Subscriptions.&amp;nbsp;So I went into SQL Management Studio and connected to Reporting Services. I could see some stuff but I couldn&amp;#39;t view details of anything. Those options were greyed out.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;I read the Books Online stuff about authentication modes etc. but my brain&amp;nbsp;started to hurt. I&amp;#39;m not a web security guru! So I asked the question on StackOverflow (&lt;a href="http://stackoverflow.com/questions/1540800/sql-2008-reporting-services-i-have-no-rights"&gt;http://stackoverflow.com/questions/1540800/sql-2008-reporting-services-i-have-no-rights&lt;/a&gt;) and got the answer. Thanks, Mozy.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana"&gt;&lt;font size="2"&gt;To cut a long story short, when you go into IE in Windows 7 UAC ensures that, even though your account is an Administrator, once you log in you are no longer running with those privileges. So, when you get to the Report Manager you are a nobody. So you have to add http://&amp;lt;machine-name&amp;gt; to your trusted sites. Then you have to use Run As Administrator on IE to get into Report Manager and then add your own login as a System Administrator in Site Security. Finally you can actually try the technology out.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana"&gt;&lt;font size="2"&gt;I just don&amp;#39;t think I was trying to do anything exotic here, Microsoft. I&amp;#39;m a reasonably accomplished .NET developer, DBA, and Reporting administrator and developer in SQL 2005. And I&amp;#39;ve got completely stuck twice now using two of your flagship new products in their &amp;#39;out of the box&amp;#39; configuration. There may be perfectly sound &amp;#39;secure by default&amp;#39; reasons for these things but please make it easier to discover how to switch the stuff on. With PowerShell you can&amp;#39;t even run your own scripts on your own machine without making some changes but that was quite well publicised and it&amp;#39;s easy to find the instructions. But I haven&amp;#39;t found it like that with SQL Server 2008. Maybe I missed some excellent advice about all this somewhere in Books Online. I don&amp;#39;t think so but, if I did, that&amp;#39;s the point: it was easily missable! Please don&amp;#39;t assume that, just because it&amp;#39;s a server product, it&amp;#39;s going to be set up by geek gods who instinctively understand a wide range of network and security details. I suspect it usually won&amp;#39;t be. And it certainly wasn&amp;#39;t this time!&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12391" width="1" height="1"&gt;</content><author><name>DavidWimbush</name><uri>http://sqlblogcasts.com/members/DavidWimbush.aspx</uri></author><category term="Reporting Services" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Reporting+Services/default.aspx" /><category term="SQL Server 2008" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/SQL+Server+2008/default.aspx" /></entry><entry><title>Backup compression on SQL 2005</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/09/24/backup-compression-on-sql-2005.aspx" /><id>http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/09/24/backup-compression-on-sql-2005.aspx</id><published>2009-09-24T09:13:00Z</published><updated>2009-09-24T09:13:00Z</updated><content type="html">&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;Last night, after a lot of preparation, I finally flicked the switch on the backup compression solution I&amp;#39;ve been implementing. The results were dramatic but in a good way:&lt;/font&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;backup jobs 60% faster&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;50% disk space saving&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;Reporting &amp;amp; BI build 30% faster&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Reporting &amp;amp; BI ready 3 hours earlier than before&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;Each night&amp;nbsp;my SQL Agent job&amp;nbsp;runs a full backup of the live databases and copies the backup files to a file server folder from where they are later backed up to tape. The last step kicks off another job on my reporting server which restores from the file server&amp;#39;s copy of the backup files and then rebuilds the data warehouse database and Analysis Services cubes. &lt;/font&gt;&lt;font size="2" face="Verdana"&gt;The whole process was only just finishing in time for the start of the business day. This morning it was all over by 04:15.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;Backup compression substantially speeds up backups and restores by using more CPU and RAM and less disk I/Os. Because the disk is the bottleneck you get a faster run time and a smaller backup file. SQL 2005 doesn&amp;#39;t have native backup compression, unlike SQL 2008, so you need a third party utility. I used Idera&amp;#39;s SQLSafe Freeware Edition. I have no connection with Idera. I simply spotted the product&amp;nbsp;when I was looking into how much compression might cost. The price was great ($0!), so I tried the product&amp;nbsp;and liked it.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;And it all worked first time!&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;&amp;nbsp;&lt;/p&gt;&lt;/font&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12335" width="1" height="1"&gt;</content><author><name>DavidWimbush</name><uri>http://sqlblogcasts.com/members/DavidWimbush.aspx</uri></author><category term="SQL Server 2005" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/SQL+Server+2005/default.aspx" /><category term="Backup &amp;amp; Restore" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Backup+_2600_amp_3B00_+Restore/default.aspx" /></entry><entry><title>Column length in SQL 2005 Analysis Services cube</title><link rel="alternate" type="text/html" href="http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/09/18/column-length-in-sql-2005-analysis-services-cube.aspx" /><id>http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/09/18/column-length-in-sql-2005-analysis-services-cube.aspx</id><published>2009-09-18T09:20:00Z</published><updated>2009-09-18T09:20:00Z</updated><content type="html">&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;I&amp;#39;ve been dark for a while as I&amp;#39;ve been on holiday in Turkey on the &amp;#39;Tourqoise Coast&amp;#39;. Great people, hot and sunny, amazing diving water, thoroughly recommended.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;Anyway. I had a new one today with a cube. A few weeks ago, in the underlying database, a varchar column&amp;#39;s max length was increased from 50 to 100. The cube continued to build fine until somebody created a new row with a value longer than 50 characters. The cube failed to build with an error about binding. Annoyingly, refreshing the data source view wasn&amp;#39;t enough. I had to go into the dimension and actually update the properties there too.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="verdana,geneva"&gt;Worth bearing in mind.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12299" width="1" height="1"&gt;</content><author><name>DavidWimbush</name><uri>http://sqlblogcasts.com/members/DavidWimbush.aspx</uri></author><category term="BI" scheme="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/BI/default.aspx" /></entry></feed>