<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>SQL Server Community Blogs</title><link>http://sqlblogcasts.com/blogs/</link><description>Voices of the SQL Server Community</description><dc:language>en-US</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/UkSqlServerCommunityBlogs" type="application/rss+xml" /><item><title>NOCOUNT and linked servers</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/3tyBGEe1qrg/NOCOUNT-and-Linked-Servers.aspx</link><pubDate>Sat, 11 Jul 2009 15:16:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11970</guid><dc:creator>MartinBell</dc:creator><slash:comments>1</slash:comments><description>The other day I was looking at calling remote stored procedures on a linked server when I hit upon this problem or feature, depending on you point of view!!...(&lt;a href="http://sqlblogcasts.com/blogs/martinbell/archive/2009/07/11/NOCOUNT-and-Linked-Servers.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11970" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/martinbell/archive/tags/NOCOUNT/default.aspx">NOCOUNT</category><category domain="http://sqlblogcasts.com/blogs/martinbell/archive/tags/Linked+Server/default.aspx">Linked Server</category><feedburner:origLink>http://sqlblogcasts.com/blogs/martinbell/archive/2009/07/11/NOCOUNT-and-Linked-Servers.aspx</feedburner:origLink></item><item><title>Best practices on setting NOCOUNT</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/Y7TV-Z3HeAo/Best-practices-on-setting-NOCOUNT.aspx</link><pubDate>Sat, 11 Jul 2009 15:15:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11969</guid><dc:creator>MartinBell</dc:creator><slash:comments>0</slash:comments><description>Setting NOCOUNT ON in stored procedures can have performance benefits, but that is not the only reason to SET NOCOUNT....(&lt;a href="http://sqlblogcasts.com/blogs/martinbell/archive/2009/07/11/Best-practices-on-setting-NOCOUNT.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11969" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/martinbell/archive/tags/Best+Practices/default.aspx">Best Practices</category><category domain="http://sqlblogcasts.com/blogs/martinbell/archive/tags/NOCOUNT/default.aspx">NOCOUNT</category><feedburner:origLink>http://sqlblogcasts.com/blogs/martinbell/archive/2009/07/11/Best-practices-on-setting-NOCOUNT.aspx</feedburner:origLink></item><item><title>String concatenation with max types stops plan caching</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/nDUh-PBVPAc/String-concatenation-with-max-types-stops-plan-caching.aspx</link><pubDate>Sat, 11 Jul 2009 14:57:22 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11971</guid><dc:creator>simonsabin</dc:creator><slash:comments>0</slash:comments><description>
&lt;p&gt;Erland Sommarskog (&lt;a href="http://www.sommarskog.se/"&gt;http://www.sommarskog.se/&lt;/a&gt;) was recently 
investigating delimited strings and was finding odd behaviour, which he wanted 
verifying. The behaviour was that he was getting recompiles with certain 
functions he was using for string splitting.&lt;/p&gt;
&lt;p&gt;I had a look and found exactly the same behaviour.&lt;/p&gt;
&lt;p&gt;I started dissecting the code and found the issue was with string 
concatenation and use of tables. These two sps identify the problem&lt;/p&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;create&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;procedure&lt;/span&gt;&lt;font color="#000000"&gt; usp_CollationBug&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;@param &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;nvarchar&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;&lt;span style="COLOR:fuchsia;"&gt;max&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;as&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;SELECT&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;top&lt;/span&gt;&lt;font color="#000000"&gt; 1 
@param &lt;/font&gt;&lt;span style="COLOR:gray;"&gt;+&lt;/span&gt;&lt;span style="COLOR:red;"&gt;N&amp;#39;,&amp;#39;&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;AS&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;output&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR:blue;"&gt;FROM&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:green;"&gt;sys&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;span style="COLOR:green;"&gt;objects&lt;/span&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;go&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;create&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;procedure&lt;/span&gt;&lt;font color="#000000"&gt; usp_CollationBugTest&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;as&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;dbcc&lt;/span&gt;&lt;font color="#000000"&gt; 
freeproccache&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;exec&lt;/span&gt;&lt;font color="#000000"&gt; usp_CollationBug&lt;/font&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;N&amp;#39;1,2,3&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:red;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;SELECT&lt;/span&gt;&lt;font color="#000000"&gt; o&lt;/font&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;font color="#000000"&gt;name&lt;/font&gt;&lt;span style="COLOR:gray;"&gt;,*&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;FROM&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:green;"&gt;sys&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;span style="COLOR:green;"&gt;dm_exec_cached_plans&lt;/span&gt;&lt;font color="#000000"&gt; 
cp&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:gray;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;OUTER&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:gray;"&gt;APPLY&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;&lt;span style="COLOR:green;"&gt;sys&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;span style="COLOR:green;"&gt;dm_exec_query_plan&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;&lt;font color="#000000"&gt;cp&lt;/font&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;font color="#000000"&gt;plan_handle&lt;/font&gt;&lt;span style="COLOR:gray;"&gt;)&lt;/span&gt;&lt;font color="#000000"&gt; qp 
&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&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;/font&gt;&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;LEFT&lt;/span&gt;&lt;font color="#000000"&gt; 
&lt;/font&gt;&lt;span style="COLOR:gray;"&gt;JOIN&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:green;"&gt;sys&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;span style="COLOR:green;"&gt;objects&lt;/span&gt;&lt;font color="#000000"&gt; o &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;ON&lt;/span&gt;&lt;font color="#000000"&gt; qp&lt;/font&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;font color="#000000"&gt;objectid &lt;/font&gt;&lt;span style="COLOR:gray;"&gt;=&lt;/span&gt;&lt;font color="#000000"&gt; o&lt;/font&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;span style="COLOR:fuchsia;"&gt;object_id&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;WHERE&lt;/span&gt;&lt;font color="#000000"&gt; qp&lt;/font&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;dbid&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:gray;"&gt;=&lt;/span&gt;&lt;font color="#000000"&gt; 
&lt;/font&gt;&lt;span style="COLOR:fuchsia;"&gt;db_id&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR:gray;"&gt;and&lt;/span&gt;&lt;font color="#000000"&gt; o&lt;/font&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;font color="#000000"&gt;name &lt;/font&gt;&lt;span style="COLOR:gray;"&gt;=&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:red;"&gt;&amp;#39;usp_CollationBug&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;span style="LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;ORDER&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;BY&lt;/span&gt;&lt;font color="#000000"&gt; o&lt;/font&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;font color="#000000"&gt;name&lt;/font&gt;&lt;/span&gt;&lt;span style="LINE-HEIGHT:115%;FONT-SIZE:8pt;mso-bidi-font-size:11.0pt;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;/span&gt;If you execute usp_CollationBugTest 
then you will find that there is no record returned in the last query, i.e. 
there isn&amp;#39;t a cached query plan.&lt;/p&gt;
&lt;p&gt;So what is causing it. Well if you take off the string concatenation (+ N&amp;#39;,&amp;#39;) 
or the FROM sysobjects you will get a query plan cached&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;alter&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;procedure&lt;/span&gt; usp_CollationBug&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;@param &lt;span style="COLOR:blue;"&gt;nvarchar&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;&lt;span style="COLOR:fuchsia;"&gt;max&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;as&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;SELECT&lt;/span&gt; 
@param &lt;span style="COLOR:gray;"&gt;+&lt;/span&gt;&lt;span style="COLOR:red;"&gt;N&amp;#39;,&amp;#39;&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; 
&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;AS&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;output&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;go&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;exec&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt; 
usp_CollationBugTest&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;go&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;alter&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;procedure&lt;/span&gt; usp_CollationBug&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;@param &lt;span style="COLOR:blue;"&gt;nvarchar&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;&lt;span style="COLOR:fuchsia;"&gt;max&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;as&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;SELECT&lt;/span&gt; 
&lt;span style="COLOR:blue;"&gt;top&lt;/span&gt; 1 @param &lt;span style="COLOR:blue;"&gt;AS&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;output&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;from&lt;/span&gt; 
&lt;span style="COLOR:green;"&gt;sys&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;span style="COLOR:green;"&gt;objects&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; 
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;go&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;exec&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt; 
usp_CollationBugTest&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;span style="LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;go&lt;/span&gt;&lt;span style="LINE-HEIGHT:115%;FONT-SIZE:5pt;mso-bidi-font-size:11.0pt;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Both of these should return a cached plan.&lt;/p&gt;
&lt;p&gt;So I thought about using a CTE, using CHAR&amp;nbsp;to append the string, or 
using varchar and not Nvarchar&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;alter&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;procedure&lt;/span&gt; usp_CollationBug&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;@param &lt;span style="COLOR:blue;"&gt;nvarchar&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;&lt;span style="COLOR:fuchsia;"&gt;max&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;as&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;with&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;param&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;as&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;select&lt;/span&gt; @param &lt;span style="COLOR:gray;"&gt;+&lt;/span&gt; 
&lt;span style="COLOR:red;"&gt;&amp;#39;,&amp;#39;&lt;/span&gt; value&lt;span style="COLOR:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;SELECT&lt;/span&gt; 
&lt;span style="COLOR:blue;"&gt;top&lt;/span&gt; 1 &lt;span style="COLOR:blue;"&gt;param&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;value&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;AS&lt;/span&gt; 
&lt;span style="COLOR:blue;"&gt;output&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;from&lt;/span&gt; 
&lt;span style="COLOR:green;"&gt;sys&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;span style="COLOR:green;"&gt;objects&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; 
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;cross&lt;/span&gt; 
&lt;span style="COLOR:gray;"&gt;join&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;param&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;go&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;exec&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt; 
usp_CollationBugTest&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;go&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;alter&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;procedure&lt;/span&gt; usp_CollationBug&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;@param n&lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;&lt;span style="COLOR:fuchsia;"&gt;max&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;)&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;as&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;SELECT&lt;/span&gt; 
&lt;span style="COLOR:blue;"&gt;top&lt;/span&gt; 1 @param &lt;span style="COLOR:gray;"&gt;+&lt;/span&gt; 
&lt;span style="COLOR:blue;"&gt;char&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;44&lt;span style="COLOR:gray;"&gt;)&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;AS&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;output&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;from&lt;/span&gt; 
&lt;span style="COLOR:green;"&gt;sys&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;span style="COLOR:green;"&gt;objects&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; 
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;go&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;exec&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt; 
usp_CollationBugTest&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;span style="LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;go&lt;/span&gt;&lt;/p&gt;&lt;span style="LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;
&lt;p style="MARGIN:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;span style="LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;alter&lt;/span&gt;&lt;span style="LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;procedure&lt;/span&gt;&lt;font color="#000000"&gt; 
usp_CollationBug&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;@param &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;&lt;span style="COLOR:fuchsia;"&gt;max&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;as&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;SELECT&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;top&lt;/span&gt;&lt;font color="#000000"&gt; 1 @param &lt;/font&gt;&lt;span style="COLOR:gray;"&gt;+&lt;/span&gt;&lt;span style="COLOR:red;"&gt;&amp;#39;,&amp;#39;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;AS&lt;/span&gt;&lt;font color="#000000"&gt; 
&lt;/font&gt;&lt;span style="COLOR:blue;"&gt;output&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;from&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:green;"&gt;sys&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;span style="COLOR:green;"&gt;objects&lt;/span&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;go&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;exec&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;font color="#000000"&gt; usp_CollationBugTest&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;go&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;But unfortunately none of these work.&lt;/p&gt;
&lt;p&gt;So far I&amp;#39;ve found two solutions, one is to force the collation of the 
expression and the second is to not use MAX datatypes&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;alter&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;procedure&lt;/span&gt; usp_CollationBug&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;@param &lt;span style="COLOR:blue;"&gt;nvarchar&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;&lt;span style="COLOR:fuchsia;"&gt;max&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;as&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;SELECT&lt;/span&gt; 
&lt;span style="COLOR:blue;"&gt;top&lt;/span&gt; 1 @param &lt;span style="COLOR:gray;"&gt;+&lt;/span&gt; 
&lt;span style="COLOR:red;"&gt;N&amp;#39;,&amp;#39;&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;COLLATE&lt;/span&gt; 
SQL_Latin1_General_CP1_CI_AS&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;AS&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;output&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;from&lt;/span&gt; 
&lt;span style="COLOR:green;"&gt;sys&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;span style="COLOR:green;"&gt;objects&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; 
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;go&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;exec&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt; 
usp_CollationBugTest&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;go&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;alter&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;procedure&lt;/span&gt; usp_CollationBug&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;@param &lt;span style="COLOR:blue;"&gt;nvarchar&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;4000&lt;span style="COLOR:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;as&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;SELECT&lt;/span&gt; 
&lt;span style="COLOR:blue;"&gt;top&lt;/span&gt; 1 @param &lt;span style="COLOR:gray;"&gt;+&lt;/span&gt; 
&lt;span style="COLOR:red;"&gt;N&amp;#39;,&amp;#39;&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;COLLATE&lt;/span&gt; 
SQL_Latin1_General_CP1_CI_AS&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;AS&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;output&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;from&lt;/span&gt; 
&lt;span style="COLOR:green;"&gt;sys&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;span style="COLOR:green;"&gt;objects&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; 
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;go&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;exec&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt; 
usp_CollationBugTest&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;go&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:7pt;mso-bidi-font-size:10.0pt;mso-no-proof:yes;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I thought about this more and thought about using STUFF, I came up with the 
following solution that does result in a cached plan&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;alter&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;procedure&lt;/span&gt; usp_CollationBug&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;@param &lt;span style="COLOR:blue;"&gt;nvarchar&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;&lt;span style="COLOR:fuchsia;"&gt;max&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;as&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;SELECT&lt;/span&gt; 
&lt;span style="COLOR:blue;"&gt;top&lt;/span&gt; 1 &lt;span style="COLOR:fuchsia;"&gt;stuff&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;@param&lt;span style="COLOR:gray;"&gt;,&lt;/span&gt;&lt;span style="COLOR:fuchsia;"&gt;LEN&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;@param&lt;span style="COLOR:gray;"&gt;),&lt;/span&gt;1&lt;span style="COLOR:gray;"&gt;,&lt;/span&gt; &lt;span style="COLOR:gray;"&gt;right(&lt;/span&gt;@param&lt;span style="COLOR:gray;"&gt;,&lt;/span&gt;1&lt;span style="COLOR:gray;"&gt;)&lt;/span&gt; &lt;span style="COLOR:gray;"&gt;+&lt;/span&gt; &lt;span style="COLOR:red;"&gt;N&amp;#39;,&amp;#39;&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;)&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;AS&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;output&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;from&lt;/span&gt; 
&lt;span style="COLOR:green;"&gt;sys&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;span style="COLOR:green;"&gt;objects&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; 
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;go&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;exec&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt; 
usp_CollationBugTest&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-bidi-font-size:14.0pt;mso-no-proof:yes;"&gt;go&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I then thought about my post&amp;nbsp;&lt;a href="http://sqlblogcasts.com/blogs/simons/archive/2005/11/18/when-is-varchar-max--not-a-varchar-max-.aspx"&gt;when 
is varchar(max) not a varchar(max)&lt;/a&gt;&amp;nbsp;This highlights that you have 
to&amp;nbsp;make sure your input variables are of a max type&amp;nbsp;to get a max type 
out. So I tried the following, and found it worked.&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;alter&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;procedure&lt;/span&gt; 
usp_CollationBug&lt;br /&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;@param &lt;span style="COLOR:blue;"&gt;nvarchar&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;&lt;span style="COLOR:fuchsia;"&gt;max&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;as&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;SELECT&lt;/span&gt; 
&lt;span style="COLOR:blue;"&gt;top&lt;/span&gt; 1 @param &lt;span style="COLOR:gray;"&gt;+&lt;/span&gt; 
&lt;span style="COLOR:fuchsia;"&gt;cast&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;&lt;span style="COLOR:red;"&gt;N&amp;#39;,&amp;#39;&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;as&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;nvarchar&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;&lt;span style="COLOR:fuchsia;"&gt;max&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;))&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;AS&lt;/span&gt; 
&lt;span style="COLOR:blue;"&gt;output&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;from&lt;/span&gt; 
&lt;span style="COLOR:green;"&gt;sys&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;.&lt;/span&gt;&lt;span style="COLOR:green;"&gt;objects&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;go&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;exec&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt; usp_CollationBugTest&lt;br /&gt;&lt;/span&gt;&lt;span style="LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;go&lt;/span&gt;&lt;span style="LINE-HEIGHT:115%;FONT-SIZE:10pt;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;Many people use MAX data types as an easy opt out, DONT as it will lead to 
this problem if you are concatenating&lt;/p&gt;
&lt;p&gt;The forcing of the collation should not be a problem as you have to specify 
it for your server, database and columns&lt;/p&gt;
&lt;p&gt;So now you know the solution, why is it important. Query plans are essential 
for the performance of queries that are regularly executed, to avoid the compile 
time, this is especially true in OLTP systems. &lt;/p&gt;
&lt;p&gt;
&lt;p&gt;If you do have a query that is executed 100s of times per second , avoiding 
compilation will more than likely improve performance&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;hr /&gt;
-

&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
 &lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11971" width="1" height="1"&gt;</description><feedburner:origLink>http://sqlblogcasts.com/blogs/simons/archive/2009/07/11/String-concatenation-with-max-types-stops-plan-caching.aspx</feedburner:origLink></item><item><title>CTE in a View</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/JqfgY1P9qYQ/cte-in-a-view.aspx</link><pubDate>Sat, 11 Jul 2009 10:51:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11968</guid><dc:creator>Madhivanan</dc:creator><slash:comments>0</slash:comments><description>It is possible to use Common Table Expression in a View. But newbies wonder why the following is not possible create view numbers as with numbers ( n ) as ( select 1 as n union all select n + 1 from numbers where n &amp;lt; 10000 ) select n from numbers option ( maxrecursion 0 ) Which when created results to the error Msg 156, Level 15, State 1, Procedure numbers, Line 15 Incorrect syntax near the keyword &amp;#39;option&amp;#39;. The correct way of doing it is to create a view without option ( maxrecursion...(&lt;a href="http://sqlblogcasts.com/blogs/madhivanan/archive/2009/07/11/cte-in-a-view.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11968" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/madhivanan/archive/tags/sql+server/default.aspx">sql server</category><category domain="http://sqlblogcasts.com/blogs/madhivanan/archive/tags/T-sql/default.aspx">T-sql</category><category domain="http://sqlblogcasts.com/blogs/madhivanan/archive/tags/view/default.aspx">view</category><category domain="http://sqlblogcasts.com/blogs/madhivanan/archive/tags/CTE/default.aspx">CTE</category><feedburner:origLink>http://sqlblogcasts.com/blogs/madhivanan/archive/2009/07/11/cte-in-a-view.aspx</feedburner:origLink></item><item><title>Dependency tracking hell</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/3l3WLzVdbwg/Dependency-tracking-hell.aspx</link><pubDate>Sat, 11 Jul 2009 09:35:54 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11967</guid><dc:creator>simonsabin</dc:creator><slash:comments>0</slash:comments><description>
&lt;p&gt;I&amp;#39;ve recently started on a project to move a system from 
one database to another. The system consists of normal database objects, 
integration services packages and SQL agent jobs.&lt;/p&gt;
&lt;p&gt;As part of the excercise I&amp;#39;m trying to identify dependencies so we make sure 
when we move, we move all the objects we need.&lt;/p&gt;
&lt;p&gt;For database objects its not too bad. I am using SQL 2005 and so 
sqldependencies can give me these dependencies (sort of, not 100% reliable). 
When I get to SQL Agent jobs and SSIS packages I&amp;#39;m stuck. It comes down to 
painful had checking and lots of &amp;quot;Find in Files&amp;quot; to find dependencies&lt;/p&gt;
&lt;p&gt;I would love a product that I could point at a table and build the dependency 
across jobs, packages as a minimum.&lt;/p&gt;
&lt;hr /&gt;
-

&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
 &lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11967" width="1" height="1"&gt;</description><feedburner:origLink>http://sqlblogcasts.com/blogs/simons/archive/2009/07/11/Dependency-tracking-hell.aspx</feedburner:origLink></item><item><title>Visual Studio Database Professional GDR R2 - Support for SQL 2008</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/W-WE4EaxeG0/Visual-Studio-Database-Professional-GDR-R2---Support-for-SQL-2008.aspx</link><pubDate>Sat, 11 Jul 2009 09:32:05 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11966</guid><dc:creator>simonsabin</dc:creator><slash:comments>0</slash:comments><description>
&lt;p&gt;I&amp;#39;ve just been installing VS a fresh and went looking 
for the Visual Studio Database Professional GDR and found that a GDR R2 had been 
released that supports SQL 2008. You can download it here &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=BB3AD767-5F69-4DB9-B1C9-8F55759846ED&amp;amp;displaylang=en#filelist"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=BB3AD767-5F69-4DB9-B1C9-8F55759846ED&amp;amp;displaylang=en#filelist&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So on top of all the great things that you get with GDR you also get support 
for all the new features in SQL 2008, including the types, the TSQL Statements, 
Certificates etc.&lt;/p&gt;
&lt;p&gt;And don&amp;#39;t forget that if you have Visual Studio Team System Developer Edition 
you can get the Database edition for free. In Visual Studio&amp;nbsp;2010 they will 
be combined into a single product.&lt;/p&gt;
&lt;hr /&gt;
-

&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
 &lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11966" width="1" height="1"&gt;</description><feedburner:origLink>http://sqlblogcasts.com/blogs/simons/archive/2009/07/11/Visual-Studio-Database-Professional-GDR-R2---Support-for-SQL-2008.aspx</feedburner:origLink></item><item><title>SQLBits yn fynd Gorllewin</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/zkdNCT9fAwQ/SQLBits-yn-fynd-Gorllewin.aspx</link><pubDate>Tue, 07 Jul 2009 17:37:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11959</guid><dc:creator>MartinBell</dc:creator><slash:comments>0</slash:comments><description>SQLBits yn fynd Gorllewin... what does that mean?...(&lt;a href="http://sqlblogcasts.com/blogs/martinbell/archive/2009/07/07/SQLBits-yn-fynd-Gorllewin.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11959" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/martinbell/archive/tags/SQLBits/default.aspx">SQLBits</category><feedburner:origLink>http://sqlblogcasts.com/blogs/martinbell/archive/2009/07/07/SQLBits-yn-fynd-Gorllewin.aspx</feedburner:origLink></item><item><title>SQL Server Technical Roll up for July 2009</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/OW4Dd8te4z4/sql-server-technical-roll-up-for-july-2009.aspx</link><pubDate>Mon, 06 Jul 2009 13:05:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11950</guid><dc:creator>tonyrogerson</dc:creator><slash:comments>1</slash:comments><description>Thanks to Vicki Collins for this technical rollup; some interesting stuff to check out... News Microsoft Releases SQL Server 2008 Service Pack 1 Microsoft has released SQL Server 2008 Service Pack 1 with enhancements meant to ease deployment but no brand new features. http://www.eweek.com/c/a/Database/Microsoft-Releases-SQL-Server-2008-Service-Pack-1-687774/ SQL Server to Get Real-Time Boost The next release of Microsoft&amp;#39;s SQL Server database, code-named &amp;quot;Kilimanjaro,&amp;quot; will offer master...(&lt;a href="http://sqlblogcasts.com/blogs/tonyrogerson/archive/2009/07/06/sql-server-technical-roll-up-for-july-2009.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11950" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/tonyrogerson/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://sqlblogcasts.com/blogs/tonyrogerson/archive/tags/Support/default.aspx">Support</category><category domain="http://sqlblogcasts.com/blogs/tonyrogerson/archive/tags/SQL+Development/default.aspx">SQL Development</category><feedburner:origLink>http://sqlblogcasts.com/blogs/tonyrogerson/archive/2009/07/06/sql-server-technical-roll-up-for-july-2009.aspx</feedburner:origLink></item><item><title>Housekeeping backup and restore history</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/kCfJWaoSkYw/housekeeping-backup-and-restore-history.aspx</link><pubDate>Mon, 06 Jul 2009 10:03:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11949</guid><dc:creator>DavidWimbush</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;Every backup and restore event is logged in history tables in msdb and these tables can get out of hand, especially if you&amp;#39;re using log shipping. Here&amp;#39;s one way to sort it out that will catch up with the backlog and then keep your history tables trimmed.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;This code will delete the oldest days worth of history as long as it&amp;#39;s more than 30 days ago:&lt;/font&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE:8pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Consolas;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--Delete earliest day of backup and restore history if it&amp;#39;s older than 30 days.&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--This way you can clear a long history a bit at a time.&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;use &lt;/span&gt;msdb&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;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;@oldest_backup_date&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;smalldatetime&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , @oldest_restore_date&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;smalldatetime&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , @oldest_date&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;smalldatetime&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;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--Find the oldest backup date (can be null)&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;@oldest_backup_date = &lt;span style="COLOR:blue;"&gt;min&lt;/span&gt;(backup_finish_date) &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;backupset &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;&lt;span style="COLOR:blue;"&gt;where&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;backup_finish_date &lt;span style="COLOR:blue;"&gt;is not null&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 &lt;/span&gt;@oldest_backup_date = &lt;span style="COLOR:blue;"&gt;isnull&lt;/span&gt;(@oldest_backup_date, &lt;span style="COLOR:#a31515;"&gt;&amp;#39;01-JUN-2079&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;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--Find the oldest restore date (can be null)&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;@oldest_restore_date = &lt;span style="COLOR:blue;"&gt;min&lt;/span&gt;(restore_date) &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;restorehistory &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;&lt;span style="COLOR:blue;"&gt;where&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;restore_date &lt;span style="COLOR:blue;"&gt;is not null&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 &lt;/span&gt;@oldest_restore_date = &lt;span style="COLOR:blue;"&gt;isnull&lt;/span&gt;(@oldest_restore_date, &lt;span style="COLOR:#a31515;"&gt;&amp;#39;01-JUN-2079&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;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--Determine the earlier of the two dates&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;if &lt;/span&gt;@oldest_restore_date &amp;lt; @oldest_backup_date&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;set &lt;/span&gt;@oldest_date = @oldest_restore_date&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;set &lt;/span&gt;@oldest_date = @oldest_backup_date&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;print &lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;#39;Oldest date is &amp;#39; &lt;/span&gt;+ &lt;span style="COLOR:blue;"&gt;convert&lt;/span&gt;(&lt;span style="COLOR:blue;"&gt;varchar&lt;/span&gt;(10), @oldest_date, 103)&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;--If it&amp;#39;s more than 30 days ago delete it&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;if &lt;/span&gt;@oldest_date &amp;gt;= &lt;span style="COLOR:blue;"&gt;dateadd&lt;/span&gt;(&lt;span style="COLOR:blue;"&gt;day&lt;/span&gt;, -30, &lt;span style="COLOR:blue;"&gt;getdate&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; &lt;span style="COLOR:blue;"&gt;print &lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;#39;no action&amp;#39;&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; &lt;span style="COLOR:blue;"&gt;print &lt;/span&gt;&lt;span style="COLOR:#a31515;"&gt;&amp;#39;deleting history&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; &lt;span style="COLOR:green;"&gt;--sp_delete_backuphistory deletes everything earlier than @oldest_date.&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;--Add 1 day otherwise it won&amp;#39;t delete anything.&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;set &lt;/span&gt;@oldest_date = &lt;span style="COLOR:blue;"&gt;dateadd&lt;/span&gt;(&lt;span style="COLOR:blue;"&gt;day&lt;/span&gt;, 1, @oldest_date)&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;exec &lt;/span&gt;sp_delete_backuphistory @oldest_date&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;p&gt;&lt;font face="Verdana" size="2"&gt;Before you implement it though, I advise you to add some indexes to msdb. Normally I wouldn&amp;#39;t screw around with system tables but I made an exception here. These tables are poorly indexed and adding some indexes makes so much difference. I found &lt;a href="http://weblogs.sqlteam.com/geoffh/archive/2008/01/21/MSDB-Performance-Tuning.aspx"&gt;this post&lt;/a&gt; on Geoff Hiten&amp;#39;s blog and brought the script up to date:&lt;/font&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE:8pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Consolas;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;-- msdb performance indexes for SQL Server 2005&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;-- History:&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;-- 12/12/2005 Geoff N. Hiten &lt;/span&gt;&lt;span style="COLOR:green;"&gt;Created (http://weblogs.sqlteam.com/geoffh/archive/2008/01/21/MSDB-Performance-Tuning.aspx).&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;-- 06/07/2009 David Wimbush &lt;/span&gt;&amp;nbsp; &lt;span style="COLOR:green;"&gt;Commented out indexes that Microsoft have implemented.&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;-- &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;Added an index on restorehistory restore_date.&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;use &lt;/span&gt;msdb &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:green;"&gt;--backupset &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--implemented by Microsoft&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--create index IX_backupset_backup_set_id on backupset(backup_set_id) &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--go &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--implemented by Microsoft&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--create index IX_backupset_backup_set_uuid on backupset(backup_set_uuid) &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--go &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;create index &lt;/span&gt;IX_backupset_media_set_id &lt;span style="COLOR:blue;"&gt;on &lt;/span&gt;backupset(media_set_id) &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;create index &lt;/span&gt;IX_backupset_backup_finish_date &lt;span style="COLOR:blue;"&gt;on &lt;/span&gt;backupset(backup_finish_date) &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;create index &lt;/span&gt;IX_backupset_backup_start_date &lt;span style="COLOR:blue;"&gt;on &lt;/span&gt;backupset(backup_start_date) &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:green;"&gt;--backupmediaset &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--implemented by Microsoft&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--create index IX_backupmediaset_media_set_id on backupmediaset(media_set_id) &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--go &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;--backupfile &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--implemented by Microsoft&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--create index IX_backupfile_backup_set_id on backupfile(backup_set_id) &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--go &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;--backupmediafamily &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--implemented by Microsoft&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--create index IX_backupmediafamily_media_set_id on backupmediafamily(media_set_id) &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--go &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;--restorehistory &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--implemented by Microsoft&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--create index IX_restorehistory_restore_history_id on restorehistory(restore_history_id) &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--go &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--implemented by Microsoft&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--create index IX_restorehistory_backup_set_id on restorehistory(backup_set_id) &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--go &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:green;"&gt;--NEW:&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;create index &lt;/span&gt;IX_restorehistory_restore_date &lt;span style="COLOR:blue;"&gt;on &lt;/span&gt;restorehistory(restore_date) &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:green;"&gt;--restorefile &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;create index &lt;/span&gt;IX_restorefile_restore_history_id &lt;span style="COLOR:blue;"&gt;on &lt;/span&gt;restorefile(restore_history_id) &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:green;"&gt;--restorefilegroup &lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;create index &lt;/span&gt;IX_restorefilegroup_restore_history_id &lt;span style="COLOR:blue;"&gt;on &lt;/span&gt;restorefilegroup(restore_history_id) &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;go &lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11949" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Backup+_2600_amp_3B00_+Restore/default.aspx">Backup &amp;amp; Restore</category><feedburner:origLink>http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/07/06/housekeeping-backup-and-restore-history.aspx</feedburner:origLink></item><item><title>Roll your own log shipping</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/jjl-FJKGpPw/roll-your-own-log-shipping.aspx</link><pubDate>Sun, 05 Jul 2009 21:02:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11947</guid><dc:creator>DavidWimbush</dc:creator><slash:comments>4</slash:comments><description>&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;I tried to use SQL Server’s built-in log shipping to set up a disaster recovery facility but I found there were some serious limitations. So, after some research, I decided to do it myself. Here’s what happened.&lt;br /&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;&lt;strong&gt;Requirements&lt;/strong&gt;&lt;br /&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;A disaster recovery plan is useless unless you can test it, preferably at least once a year. To be really sure, I think you need to prove you can fail over, use, and fail back the production systems. It’s all very well testing on a test setup – you have to make sure it works – but there’s no substitute for confirming that it actually works in the environment it’s meant to preserve. There are so many things that have to fit together and, in a disaster situation, you really don’t want find yourself saying “Crap, we didn’t think about that!” and explaining to your boss that the business is going to be down for a day or two instead of the hour or two you’d confidently promised.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;&lt;br /&gt;So you have to be able to smoothly fail over to the standby servers, have all the data consuming systems gracefully adapt to the new data sources, confirm they all work, and then reverse the process. Without losing any data. At least once a year. Easy!&lt;br /&gt;&lt;/p&gt;&lt;/font&gt;
&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;Some specific technical requirements:&lt;/font&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;font face="verdana,geneva" size="2"&gt;Setup and configuration must be scriptable. I don’t want to screw around with multi-page wizards and write reams of documentation about it. If I have to rebuild the server I want to get it done quickly and easily, and scripts are the way.&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;font face="verdana,geneva" size="2"&gt;I need it to tell me if it goes wrong, and then I need some tools to help me understand where I am and how I got there so I can fix it.&lt;/font&gt;&lt;font face="verdana,geneva" size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;font face="verdana,geneva" size="2"&gt;When failed over, I want to be able to log ship back the other way. In a real disaster this is probably not an issue but it’s vital for testing the solution. Once live transactions have been applied to the standby server you have to log ship them back to the normal live server or lose them.&lt;/div&gt;&lt;/li&gt;&lt;/font&gt;
&lt;li&gt;
&lt;div&gt;&lt;font face="verdana,geneva" size="2"&gt;I&amp;nbsp;decided to have a time lag of 3 hours before transactions are applied to the standby server. We thought we could use this to give us a chance to rescue data that was deleted by mistake.&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/font&gt;
&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;&lt;strong&gt;Trying Out-of-the-Box Log Shipping&lt;br /&gt;&lt;/p&gt;&lt;/strong&gt;&lt;/font&gt;
&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;I filled in about 11 pages of wizard, setting up the source, standby and monitor. Then I captured the script, thinking I could just copy it for each database and find and replace the database name. But the script doesn’t run! I spent quite a while searching for how to fix and couldn’t find an answer. At this point I decided I could live without the scriptability so I went through the wizard again, building a detailed installation guide for our domain.&lt;/font&gt;&lt;/p&gt;&lt;font face="verdana,geneva" size="2"&gt;
&lt;p&gt;&lt;br /&gt;It all looked great at first. There’s a report on the monitor server to show the progress of backups, file copies and restores. I failed over, putting the source database into standby mode ready to receive logs. But when I tried to restore the standby database right up to date there was no way to override the 3 hour delay I’d specified. I went into the wizard, took out the delay, restored all logs and brought the database online. My test application adapted to the new data source. Not ideal in a real disaster with everyone breathing down my neck but I can live with it.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Now to set up log shipping back the other way. I go into the wizard and it won’t let me set up the monitor. Apparently you can only monitor shipping between two servers in one direction. If you remove the initial shipping you can set it up going the other way. So that’s about 11 pages of wizard per database to failover, and the same to fail back. That’s enough of that!&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;My Way&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I looked around hoping to find that somebody else had already done a full solution but I couldn’t find one. I felt &lt;a href="http://www.simple-talk.com/sql/backup-and-recovery/pop-rivetts-sql-server-faq-no.4-pop-does-log-shipping/"&gt;Pop Rivetts Does Log Shipping&lt;/a&gt; came the closest so I cannibalised it into what I wanted.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;I have the following jobs on both servers:&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;LogShipBackup&lt;/strong&gt;&lt;br /&gt;Does a log backup on selected databases, compresses the file with &lt;a href="http://www.rarlab.com/"&gt;WinRAR&lt;/a&gt;, copies it to a share on the other server, and does housekeeping on the files and the backup/respore history tables in msdb. The copy stage copies over any files that are not on the other side so it can catch up if connection has been lost for a bit.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;LogShipBackupAlert&lt;/strong&gt;&lt;br /&gt;Sends me an email if the LogShipBackup job has not run recently and successfully. LogShipBackup will send me an email if it fails but that won’t alert me if it doesn’t run. &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;LogShipRestore&lt;/strong&gt;&lt;br /&gt;Decompresses and restores logs in sequence on selected databases, and does housekeeping on the files and the backup/respore history tables in msdb. You can specify a delay so that logs aren’t applied immediately. It checks the backup history so it doesn’t trip up if a file is copied over again. It actively kills connections to a database to ensure the restore can go ahead.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;LogShipRestoreAlert&lt;/strong&gt;&lt;br /&gt;Sends me an email if the LogShipRestore job has not run recently and successfully. LogShipRestore will send me an email if it fails but that won’t alert me if it doesn’t run. &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;LogShipFailOver&lt;/strong&gt;&lt;br /&gt;Disables the LogShipBackup and LogShipBackupAlert jobs, backs up the tail of the log on selected databases, puts them in read-only standby mode, and copies the backup files over to the other server. The copy stage copies over any files that are not on the other side so it’s quite resilient.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;LogShipBringOnline&lt;/strong&gt;&lt;br /&gt;Disables the LogShipRestore and LogShipRestoreAlert jobs, restores all logs in sequence on selected databases and brings those databases online.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;The jobs LogShipBackup and LogShipBackupAlert are enabled on the primary server, and LogShipRestore and LogShipRestoreAlert are enabled on the standby server. I run them every 15 minutes. To fail over, run LogShipFailOver on the primary and then LogShipBringOnline on the standby server.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Apart from the alert jobs, each job has one or more steps that perform the appropriate actions on a database that is shipping or receiving logs. The jobs rely on a set of stored procedures installed in both servers’ master databases.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;The code is available for download &lt;a href="http://sqlblogcasts.com/blogs/davidwimbush/files/logship.zip"&gt;here&lt;/a&gt;. If you’re interested, please feel free to check it out and use it if you want to. If it doesn’t quite do what you want you can always fix that. I’d be interested to know what you think of it. I’d also be very keen to hear from you if you’ve found ways round the problems I found with the built-in log shipping.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Recommended Reading&lt;br /&gt;&lt;/strong&gt;To find out more about log shipping I recommend the following:&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://www.sql-server-performance.com/articles/clustering/log_shipping_70_p1.aspx"&gt;Brad McGehee’s article&lt;/a&gt; about doing it yourself. It dates back to SQL 2000 days but log shipping still seems to work just the same.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;a href="http://www.sqlskills.com/blogs/paul/"&gt;Paul Randal’s posts&lt;/a&gt; about how backup and recovery work.&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/font&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11947" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/Log+Shipping/default.aspx">Log Shipping</category><feedburner:origLink>http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/07/05/roll-your-own-log-shipping.aspx</feedburner:origLink></item><item><title>Leeds Area SQL Server User Group Meeting, Leeds - Monday 20th July</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/7_xvd7SeOmw/leeds-area-sql-server-user-group-meeting-leeds-monday-20th-july.aspx</link><pubDate>Fri, 03 Jul 2009 10:39:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11939</guid><dc:creator>MartinBell</dc:creator><slash:comments>0</slash:comments><description>Managing a large SQL Server estate If size matters Martin Cairney would have the bragging rights!! Martin Cairney Martin Cairney has over 10 years experience as a SQL Server DBA. In his time he has worked for one of the largest IT services companies in the world deploying and supporting SQL Server installations from versions 6.5 through to 2005. Martin has supported some the SQL Server estate of some major Government Departments and Financial Institutions as well as a variety of occasional consultancy...(&lt;a href="http://sqlblogcasts.com/blogs/martinbell/archive/2009/07/03/leeds-area-sql-server-user-group-meeting-leeds-monday-20th-july.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11939" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/martinbell/archive/tags/User+Group/default.aspx">User Group</category><feedburner:origLink>http://sqlblogcasts.com/blogs/martinbell/archive/2009/07/03/leeds-area-sql-server-user-group-meeting-leeds-monday-20th-july.aspx</feedburner:origLink></item><item><title>SQL Nuggets</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/wRk1IKm9YG8/SQL-Nuggets.aspx</link><pubDate>Fri, 03 Jul 2009 10:15:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11938</guid><dc:creator>MartinBell</dc:creator><slash:comments>0</slash:comments><description>What are SQL Nuggets?...(&lt;a href="http://sqlblogcasts.com/blogs/martinbell/archive/2009/07/03/SQL-Nuggets.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11938" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/martinbell/archive/tags/SQL+Nuggets/default.aspx">SQL Nuggets</category><feedburner:origLink>http://sqlblogcasts.com/blogs/martinbell/archive/2009/07/03/SQL-Nuggets.aspx</feedburner:origLink></item><item><title>The next SQLbits</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/CPQBOM4Khh0/The-next-SQLbits.aspx</link><pubDate>Thu, 02 Jul 2009 00:43:08 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11937</guid><dc:creator>simonsabin</dc:creator><slash:comments>0</slash:comments><description>&lt;br /&gt;
&lt;p&gt;We&amp;#39;ll be announcing the date and venue for the next 
SQLBits on Monday&lt;/p&gt;
&lt;p&gt;So keep posted, we&amp;#39;ve got some really exciting news.&lt;/p&gt;
&lt;p&gt;I am really excited about the whole event. Its going to be bigger and better 
than the others.&lt;/p&gt;
&lt;br /&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11937" width="1" height="1"&gt;</description><feedburner:origLink>http://sqlblogcasts.com/blogs/sqlbits/archive/2009/07/02/The-next-SQLbits.aspx</feedburner:origLink></item><item><title>ROW Constructors are dead, long live Table Value Constructors!</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/vYNEHb4CAR4/ROW-CONSTRUCTORS-are-dead_2C00_-long-live-Table-Value-Constructors_2100_.aspx</link><pubDate>Wed, 01 Jul 2009 21:48:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11934</guid><dc:creator>MartinBell</dc:creator><slash:comments>0</slash:comments><description>New documentation on ROW CONSTRUCTORS indicate the feature has had a name change to Table Value Constructors...(&lt;a href="http://sqlblogcasts.com/blogs/martinbell/archive/2009/07/01/ROW-CONSTRUCTORS-are-dead_2C00_-long-live-Table-Value-Constructors_2100_.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11934" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/martinbell/archive/tags/ROW+CONSTRUCTOR/default.aspx">ROW CONSTRUCTOR</category><category domain="http://sqlblogcasts.com/blogs/martinbell/archive/tags/Table+Value+Constructor/default.aspx">Table Value Constructor</category><feedburner:origLink>http://sqlblogcasts.com/blogs/martinbell/archive/2009/07/01/ROW-CONSTRUCTORS-are-dead_2C00_-long-live-Table-Value-Constructors_2100_.aspx</feedburner:origLink></item><item><title>Cambridge usergroup meeting on Monday 6th - SQL 2008</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/c35qlx74KP4/Cambridge-usergroup-meeting-on-Monday-6th---SQL-2008.aspx</link><pubDate>Tue, 30 Jun 2009 13:19:11 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11930</guid><dc:creator>simonsabin</dc:creator><slash:comments>0</slash:comments><description>
&lt;p&gt;Don&amp;#39;t forget if you are in the Cambridge area on Monday 
(6th July 2009) we are doing another usergroup meeting.&lt;/p&gt;
&lt;p&gt;This one is going to be on SQL Server 2008 features. &lt;/p&gt;
&lt;p&gt;We are holding this at the head quarters of Redgate software who are kindly 
sponsoring the event.&lt;/p&gt;
&lt;p&gt;To register go to &lt;a href="http://sqlserverfaq.com/events/183/SQL-Server-User-Group-Cambridge-SQL-Server-2008.aspx"&gt;http://sqlserverfaq.com/events/183/SQL-Server-User-Group-Cambridge-SQL-Server-2008.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I look forward to seeing you there.&lt;/p&gt;
&lt;hr /&gt;
-

&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
 &lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11930" width="1" height="1"&gt;</description><feedburner:origLink>http://sqlblogcasts.com/blogs/simons/archive/2009/06/30/Cambridge-usergroup-meeting-on-Monday-6th---SQL-2008.aspx</feedburner:origLink></item><item><title>Don't destory your certificate if you dabble with SQL 2008 Encryption</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/Ws61GzNi9XI/Don-t-destory-your-certificate-if-you-dabble-with-SQL-2008-Encryption.aspx</link><pubDate>Tue, 30 Jun 2009 13:11:37 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11928</guid><dc:creator>simonsabin</dc:creator><slash:comments>0</slash:comments><description>
&lt;p&gt;Martin is continuing to post some great new posts on his 
blog. I thought the last one is a real nasty one.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://sqlblogcasts.com/blogs/martinbell/archive/2009/06/29/After-disabling-tde-you-still-requires-certificates-to-restore-the-database.aspx"&gt;http://sqlblogcasts.com/blogs/martinbell/archive/2009/06/29/After-disabling-tde-you-still-requires-certificates-to-restore-the-database.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you have enabled TDE on a database and encrypted some data then remove the 
TDE and backup, you may not be able to restore that backup if you don&amp;#39;t have the 
certificate. &lt;/p&gt;
&lt;p&gt;I am guessing that this is to do with the encryption when you turn TDE on 
being a background task, I expect the same is true in reverse, i.e. pages stay 
encrypted until a background process decrypts them.&lt;/p&gt;
&lt;p&gt;I wonder if the database ever gets back to a totally unencrypted 
version&lt;/p&gt;
&lt;hr /&gt;
-

&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
 &lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11928" width="1" height="1"&gt;</description><feedburner:origLink>http://sqlblogcasts.com/blogs/simons/archive/2009/06/30/Don-t-destory-your-certificate-if-you-dabble-with-SQL-2008-Encryption.aspx</feedburner:origLink></item><item><title>How to stop that annoying beep on your server</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/pxRTrm_ypJs/How-to-stop-that-annoying-beep-on-your-server.aspx</link><pubDate>Tue, 30 Jun 2009 09:45:37 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11925</guid><dc:creator>simonsabin</dc:creator><slash:comments>3</slash:comments><description>
&lt;p&gt;Many years ago&amp;nbsp;I was working on a project that had 
some large batch processing in it. To do this processing we had some dedicated 
servers, one of which sat under the desk next to me.&lt;/p&gt;
&lt;p&gt;Apart from the noise of the fan soudning like we had actually bought a jet 
fighter the most annoying thing about this processing was that it resulted 
caused the servers beep to continually sound. Something in the code caused it to 
fire. &lt;/p&gt;
&lt;p&gt;Boy it was annoying.&lt;/p&gt;
&lt;p&gt;We were never able to find out how to stop it, I think in the end we 
disconnected it. Well last week I found out and it was so annoyingly simple. 
&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;net stop beep&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Yep thats it, thanks to the trainer that pointed this out last week. As you 
can imagine, having 12 training machines all beeping is not something you really 
want&lt;/p&gt;
&lt;p&gt;To permanently stop it you have to disable the service using &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;sc config beep start= disabled&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Whats really odd is that beep doesn&amp;#39;t appear in the list of 
services&lt;/p&gt;
&lt;hr /&gt;
-

&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
 &lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11925" width="1" height="1"&gt;</description><feedburner:origLink>http://sqlblogcasts.com/blogs/simons/archive/2009/06/30/How-to-stop-that-annoying-beep-on-your-server.aspx</feedburner:origLink></item><item><title>After disabling TDE you still requires the certificate to restore the database</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/oZEo7Jvmbak/After-disabling-tde-you-still-requires-certificates-to-restore-the-database.aspx</link><pubDate>Mon, 29 Jun 2009 22:46:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11924</guid><dc:creator>MartinBell</dc:creator><slash:comments>2</slash:comments><description>Missing certificates can cause problems when restoring databases even if they are not being used!...(&lt;a href="http://sqlblogcasts.com/blogs/martinbell/archive/2009/06/29/After-disabling-tde-you-still-requires-certificates-to-restore-the-database.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11924" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/martinbell/archive/tags/Encryption/default.aspx">Encryption</category><category domain="http://sqlblogcasts.com/blogs/martinbell/archive/tags/Restore/default.aspx">Restore</category><category domain="http://sqlblogcasts.com/blogs/martinbell/archive/tags/SQL+Express/default.aspx">SQL Express</category><category domain="http://sqlblogcasts.com/blogs/martinbell/archive/tags/Certificate/default.aspx">Certificate</category><category domain="http://sqlblogcasts.com/blogs/martinbell/archive/tags/TDE/default.aspx">TDE</category><feedburner:origLink>http://sqlblogcasts.com/blogs/martinbell/archive/2009/06/29/After-disabling-tde-you-still-requires-certificates-to-restore-the-database.aspx</feedburner:origLink></item><item><title>SQL Server version has a known compatibility issues with Windows 7 RC. This warning is genuine and applies to all SQL Server editions, including all Express editions.</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/qicicF_n_CI/sql-server-version-has-a-known-compatibility-issues-with-windows-7-rc-this-warning-is-genuine-and-applies-to-all-sql-server-editions-including-all-express-editions.aspx</link><pubDate>Mon, 29 Jun 2009 10:35:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11921</guid><dc:creator>ssqa.net</dc:creator><slash:comments>0</slash:comments><description>There is no need to guess about the rootcause of the above error message, as it clearly mentions about compatibility issues as a warning.... read more !...(&lt;a href="http://sqlblogcasts.com/blogs/ssqanet/archive/2009/06/29/sql-server-version-has-a-known-compatibility-issues-with-windows-7-rc-this-warning-is-genuine-and-applies-to-all-sql-server-editions-including-all-express-editions.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11921" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/ssqanet/archive/tags/sql+server/default.aspx">sql server</category><category domain="http://sqlblogcasts.com/blogs/ssqanet/archive/tags/microsoft/default.aspx">microsoft</category><category domain="http://sqlblogcasts.com/blogs/ssqanet/archive/tags/best+practices/default.aspx">best practices</category><category domain="http://sqlblogcasts.com/blogs/ssqanet/archive/tags/download/default.aspx">download</category><category domain="http://sqlblogcasts.com/blogs/ssqanet/archive/tags/error+log/default.aspx">error log</category><category domain="http://sqlblogcasts.com/blogs/ssqanet/archive/tags/installation/default.aspx">installation</category><category domain="http://sqlblogcasts.com/blogs/ssqanet/archive/tags/express/default.aspx">express</category><category domain="http://sqlblogcasts.com/blogs/ssqanet/archive/tags/slipstream/default.aspx">slipstream</category><category domain="http://sqlblogcasts.com/blogs/ssqanet/archive/tags/editions/default.aspx">editions</category><feedburner:origLink>http://sqlblogcasts.com/blogs/ssqanet/archive/2009/06/29/sql-server-version-has-a-known-compatibility-issues-with-windows-7-rc-this-warning-is-genuine-and-applies-to-all-sql-server-editions-including-all-express-editions.aspx</feedburner:origLink></item><item><title>Hyperlinks in custom reports</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/2JQw7PHqrd8/Hyperlinks-in-custom-reports.aspx</link><pubDate>Mon, 29 Jun 2009 07:31:50 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11918</guid><dc:creator>simonsabin</dc:creator><slash:comments>2</slash:comments><description>
&lt;p&gt;One feature introduced in SQL Server 2005 is reporting in management studio. 
You have a set of standard reports that allow you to see in a nice report format 
output from dmvs and the default system background trace. Whats neat is that you 
can write your own custom reports. For those that long after the taskpad view of 
a database from SQL 2000 Enterprise manager with the help from Jasper 
Smith&amp;nbsp;I created this &lt;a href="http://sqlblogcasts.com/blogs/simons/archive/2007/03/28/Update-to-the-taskpad-custom-report.aspx"&gt;http://sqlblogcasts.com/blogs/simons/archive/2007/03/28/Update-to-the-taskpad-custom-report.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The custom report feature is almost fantastic, there are 3 main features I 
think make them awkward to use. &lt;/p&gt;
&lt;p&gt;1. You can select text from the report and copy it&lt;br /&gt;2. You can&amp;#39;t add 
additional parameters to allow additional filtering, i.e. filter audit changes 
for today.&lt;br /&gt;3. You can&amp;#39;t have hyperlinks.&lt;/p&gt;
&lt;p&gt;The last one I raised a connect item for &lt;span style="FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:11pt;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-ansi-language:EN-GB;mso-fareast-language:EN-GB;mso-bidi-language:AR-SA;"&gt;&lt;a href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=240407"&gt;https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=240407&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:11pt;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-ansi-language:EN-GB;mso-fareast-language:EN-GB;mso-bidi-language:AR-SA;"&gt;If 
we had this you could write reports that had links to KB articles, blog posts, 
or internal KB systems. Similar to what most monitoring systems 
provide.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:11pt;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-ansi-language:EN-GB;mso-fareast-language:EN-GB;mso-bidi-language:AR-SA;"&gt;If 
you think this is a good idea then please vote on the connect item. I&amp;#39;ve been 
asked by the tools team to see if it is something people want.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:11pt;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-ansi-language:EN-GB;mso-fareast-language:EN-GB;mso-bidi-language:AR-SA;"&gt;Some 
other connect items that you might be interested in supporting if you think they 
are worthwhile.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:11pt;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-ansi-language:EN-GB;mso-fareast-language:EN-GB;mso-bidi-language:AR-SA;"&gt;Use 
expressions for data sources - &lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:11pt;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-ansi-language:EN-GB;mso-fareast-language:EN-GB;mso-bidi-language:AR-SA;"&gt;&lt;a href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=238233"&gt;https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=238233&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:11pt;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-ansi-language:EN-GB;mso-fareast-language:EN-GB;mso-bidi-language:AR-SA;"&gt;Be 
able to combine data from different data sources - &lt;a href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=240268"&gt;https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=240268&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:11pt;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-ansi-language:EN-GB;mso-fareast-language:EN-GB;mso-bidi-language:AR-SA;"&gt;Be 
able to run reports against SQL 2000 database - &lt;a href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=240476"&gt;https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=240476&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY:&amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:11pt;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:&amp;#39;Times New Roman&amp;#39;;mso-ansi-language:EN-GB;mso-fareast-language:EN-GB;mso-bidi-language:AR-SA;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;hr /&gt;
-

&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
 &lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11918" width="1" height="1"&gt;</description><feedburner:origLink>http://sqlblogcasts.com/blogs/simons/archive/2009/06/29/Hyperlinks-in-custom-reports.aspx</feedburner:origLink></item><item><title>Disk Partition Alignment Best Practices for SQL Server</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/C69OAZxoajo/disk-partition-alignment-best-practices-for-sql-server.aspx</link><pubDate>Fri, 26 Jun 2009 14:57:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11916</guid><dc:creator>StevenWhite</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;&amp;nbsp;Just noticed that there is a MS new paper on Disk Partition Alignment.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=5b343389-f7c9-43d0-9892-ddcf55890529"&gt;http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=5b343389-f7c9-43d0-9892-ddcf55890529&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Happy weekend reading&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11916" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/stevenwhite/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category><feedburner:origLink>http://sqlblogcasts.com/blogs/stevenwhite/archive/2009/06/26/disk-partition-alignment-best-practices-for-sql-server.aspx</feedburner:origLink></item><item><title>Hopping mad frog wants to learn SQL Server</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/cuZkwgvg8Kg/hopping-mad-frog-wants-to-learn-sql-server.aspx</link><pubDate>Fri, 26 Jun 2009 10:32:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11914</guid><dc:creator>tonyrogerson</dc:creator><slash:comments>0</slash:comments><description>I always like working at home with my patio door open, we had a really heavy rain shower and I got a visitor. Anyway, this video is one of the instances of me chasing him/her out of my office. So much for prepping for my LiveMeeting this afternoon :) http://www.youtube.com/watch?v=vrq_0woVynE Tony....(&lt;a href="http://sqlblogcasts.com/blogs/tonyrogerson/archive/2009/06/26/hopping-mad-frog-wants-to-learn-sql-server.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11914" width="1" height="1"&gt;</description><feedburner:origLink>http://sqlblogcasts.com/blogs/tonyrogerson/archive/2009/06/26/hopping-mad-frog-wants-to-learn-sql-server.aspx</feedburner:origLink></item><item><title>Live Meeting: Creating a Star Schema and OLAP Cubes</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/6iAT5O-aPYk/live-meeting-creating-a-star-schema-and-olap-cubes.aspx</link><pubDate>Thu, 25 Jun 2009 19:06:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11911</guid><dc:creator>sqlartist</dc:creator><slash:comments>1</slash:comments><description>Hi, I just finished my first live meeting for the UK SQL Server user group on the subject of creating a star schema and OLAP cubes. I think it went well, it was recorded so Ill let you all be the judge of that - presentation to follow. I spoke way too fast, Tony Rogerson told me I sound &amp;quot;well Cockney&amp;quot; - but depressing as in my own head I sound like Hugh Grant. I spoke way too fast as I am inclinded to do but even though I got through most of my content I defintely forgot loads and apologies...(&lt;a href="http://sqlblogcasts.com/blogs/sqlartist/archive/2009/06/25/live-meeting-creating-a-star-schema-and-olap-cubes.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11911" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/sqlartist/archive/tags/Business+Intelligence/default.aspx">Business Intelligence</category><category domain="http://sqlblogcasts.com/blogs/sqlartist/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://sqlblogcasts.com/blogs/sqlartist/archive/tags/OLAP/default.aspx">OLAP</category><feedburner:origLink>http://sqlblogcasts.com/blogs/sqlartist/archive/2009/06/25/live-meeting-creating-a-star-schema-and-olap-cubes.aspx</feedburner:origLink></item><item><title>MSSQL 2008 SP1 Install - Server is in script upgrade mode. Only administrator can connect at this time</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/m1EwIwWASPc/mssql-2008-sp1-install-server-is-in-script-upgrade-mode-only-administrator-can-connect-at-this-time.aspx</link><pubDate>Thu, 25 Jun 2009 11:40:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11909</guid><dc:creator>StevenWhite</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;After taking the usual database backups etc. I went to install SP1 on&amp;nbsp;a SQL 2008 server (RTM)&lt;br /&gt;following the normal routine of stopping the sql server services and firing up the service pack install.&lt;/p&gt;
&lt;p&gt;All went fine, and the service pack finished. Anyway I rebooted the server to check everything was clean on startup.&lt;/p&gt;
&lt;p&gt;When the server came back&amp;nbsp;I checked the eventlog, and that the services started fine etc.&lt;br /&gt;Next&amp;nbsp;I used management studio to connect to the server only to get the message&lt;br /&gt;&amp;#39;&lt;em&gt;Server is in script upgrade mode. Only administrator can connect at this time.&lt;/em&gt;&amp;#39;&lt;/p&gt;
&lt;p&gt;Firstly I checked the sql log file and the event log - nothing to say why.&lt;br /&gt;Hence while I searched the web for this message and found a MS connect article&lt;/p&gt;
&lt;p&gt;&lt;a href="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=416860"&gt;http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=416860&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It turns out that the upgrade scripts run on the first startup, hence the message.&lt;br /&gt;Once the scripts have completed (which took a while), evertthing was sorted and normal access restored.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11909" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/stevenwhite/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category><feedburner:origLink>http://sqlblogcasts.com/blogs/stevenwhite/archive/2009/06/25/mssql-2008-sp1-install-server-is-in-script-upgrade-mode-only-administrator-can-connect-at-this-time.aspx</feedburner:origLink></item><item><title>Start a SQL Agent Job in SQL</title><link>http://feedproxy.google.com/~r/UkSqlServerCommunityBlogs/~3/Qbnwue5VZfQ/start-a-sql-agent-job-in-sql.aspx</link><pubDate>Wed, 24 Jun 2009 07:58:00 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11904</guid><dc:creator>DavidWimbush</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;How do you start a SQL Agent job&amp;nbsp;in SQL? I recently found myself&amp;nbsp;wanting to be able to do this and it turns out it&amp;#39;s really easy:&lt;/font&gt;&lt;/p&gt;
&lt;div style="FONT-SIZE:8pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Consolas;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;exec &lt;/span&gt;msdb.dbo.sp_start_job &lt;span style="COLOR:#a31515;"&gt;&amp;#39;Check Integrity&amp;#39;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&lt;font face="verdana,geneva" size="2"&gt;It returns as soon as the job has started, without waiting until the job has finished. You could use it to run a job from a script or a&amp;nbsp;stored procedure. But the way I use it is in the last step of a job in order to run jobs in sequence without having to guess in the schedules how to time them. No wasted time and no danger of the second job running before the first one has finished.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11904" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/davidwimbush/archive/tags/SQLAgent/default.aspx">SQLAgent</category><feedburner:origLink>http://sqlblogcasts.com/blogs/davidwimbush/archive/2009/06/24/start-a-sql-agent-job-in-sql.aspx</feedburner:origLink></item></channel></rss>
