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

<channel>
	<title>A Developer&#039;s Blog &#187; SQL Server 2005</title>
	<atom:link href="http://blog.hoegaerden.be/tag/sql-server-2005/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hoegaerden.be</link>
	<description>SQL Server, BI, .NET, IT and anything else I have been playing with.</description>
	<lastBuildDate>Sun, 11 Jul 2010 12:19:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SQL Server 2008 SP2: Want It? Vote For It!</title>
		<link>http://blog.hoegaerden.be/2010/01/20/sql-server-2008-sp2-want-it-vote-for-it/</link>
		<comments>http://blog.hoegaerden.be/2010/01/20/sql-server-2008-sp2-want-it-vote-for-it/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 21:29:52 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/2010/01/20/sql-server-2008-sp2-want-it-vote-for-it/</guid>
		<description><![CDATA[If you’re interested in seeing the next Service Pack for SQL Server 2008 released, vote for it at this Microsoft Connect page!&#160; Now that the release date for R2 has been announced, hopefully the next one is for SQL 2008 Service Pack 2.
If you’re still on 2005 and thus more interested in an SP4 for [...]]]></description>
			<content:encoded><![CDATA[<p>If you’re interested in seeing the next Service Pack for SQL Server 2008 released, <a title="Microsoft Connect: SQL Server 2008 Service Pack 2" href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=522123">vote for it at this Microsoft Connect page</a>!&#160; Now that the release date for R2 has been announced, hopefully the next one is for SQL 2008 Service Pack 2.</p>
<p>If you’re still on 2005 and thus more interested in an SP4 for that version, <a title="Microsoft Connect: Service Pack 4 for SQL Server 2005" href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=522122">it has also been posted at Connect</a>.</p>
<p>How did I find out?&#160; Through the following blog posts at SSQA.NET:</p>
<p><a title="SQL Server 2008 SP2" href="http://sqlserver-qa.net/blogs/sql2008/archive/2010/01/14/6210.aspx">SQL Server 2008 SP2</a></p>
<p><a title="SQL Server 2005 SP4" href="http://sqlserver-qa.net/blogs/sql2008/archive/2010/01/14/6211.aspx">SQL Server 2005 SP4</a></p>
<p><strong>Update (27 Feb 2010):</strong></p>
<p>SQL Server 2008 SP2 is scheduled for Q3 2010.</p>
<p>SQL Server 2005 SP4 is scheduled for Q4 2010.</p>
<p><a title="SQL Server Servicing plans" href="http://blogs.msdn.com/sqlreleaseservices/archive/2010/02/12/sql-server-servicing-plans.aspx" target="_blank">See this post on the Microsoft SQL Server Release Services blog</a> for details.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2010/01/20/sql-server-2008-sp2-want-it-vote-for-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSIS 2005 from SSMS 2008? No.</title>
		<link>http://blog.hoegaerden.be/2009/02/08/ssis-2005-from-ssms-2008-no/</link>
		<comments>http://blog.hoegaerden.be/2009/02/08/ssis-2005-from-ssms-2008-no/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 22:09:27 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[Integration Services]]></category>
		<category><![CDATA[Management Studio]]></category>
		<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SSIS]]></category>
		<category><![CDATA[SSMS]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/2009/02/08/ssis-2005-from-ssms-2008-no/</guid>
		<description><![CDATA[Having trouble connecting to your 2005 Integration Services using Management Studio 2008?  Even when you only have SQL Server Integration Services running, and not version 10.0?

To make it even better, have you noticed that SQL Server Integration Services 10.0 will start up when you connect to it from SSMS 2008?
Well, that&#8217;s by design.  SSMS 2008 [...]]]></description>
			<content:encoded><![CDATA[<p>Having trouble connecting to your 2005 Integration Services using Management Studio 2008?  Even when you only have SQL Server Integration Services running, and not version 10.0?</p>
<p><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" src="http://blog.hoegaerden.be/wp-content/uploads/image8.png" border="0" alt="Integration Services" width="457" height="40" /></p>
<p>To make it even better, have you noticed that SQL Server Integration Services 10.0 will start up when you connect to it from SSMS 2008?</p>
<p>Well, that&#8217;s by design.  SSMS 2008 can only connect to SSIS 2008.  And SSMS 2005 can only connect to SSIS 2005.  So don&#8217;t go uninstalling the 2005 Management Studio to save some space if you use Integration Services 2005!</p>
<p>There&#8217;s some (limited) info on <a title="SSMS 2008 RTM is unable to connect to SSIS 2005 SP2" href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=363010" target="_blank">Microsoft</a> <a title="Can't connect to SSIS 2005 from SSMS CTP5" href="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=315076" target="_blank">Connect</a> and on <a title="SSMS 2008 can't connect to SSIS 2005" href="http://www.sqlservercentral.com/Forums/Topic560372-391-1.aspx" target="_blank">SQL Server Central</a>.</p>
<p><strong>Update</strong>: when trying to use SSMS 2008 to connect to SSRS 2005, an error coming from the Report Server WMI provider will show up complaining about a couple of invalid namespaces (Microsoft.SqlServer.Management.UI.RSClient and System.Management).  It has been reported as a <a title="SQL 2008 Management Studio and SQL 2005 Reporting Services" href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=361680&amp;wa=wsignin1.0" target="_blank">bug on Microsoft Connect</a>.  Microsoft&#8217;s feedback is that the issue is caused by a breaking change in the WMI namespace and that it won&#8217;t be fixed.</p>
<p>So there you go, neither Reporting Services nor Integration Services 2005 can be connected to using Management Studio 2008.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2009/02/08/ssis-2005-from-ssms-2008-no/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Do not compress SQL Server folder</title>
		<link>http://blog.hoegaerden.be/2009/01/18/do-not-compress-sql-server-folder/</link>
		<comments>http://blog.hoegaerden.be/2009/01/18/do-not-compress-sql-server-folder/#comments</comments>
		<pubDate>Sun, 18 Jan 2009 12:42:40 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[SQL Server 2005]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/2009/01/18/do-not-compress-sql-server-folder/</guid>
		<description><![CDATA[This time I&#8217;ll start with the conclusion: it is not a good idea to compress the \Program Files\Microsoft SQL Server\ folder using NTFS compression, not even on a laptop with less than a GB free on the C: partition.&#160; Because if you do, you will get an error when installing SP3 for SQL Server 2005.&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>This time I&#8217;ll start with the conclusion: it is not a good idea to compress the \Program Files\Microsoft SQL Server\ folder using <a title="How To Use File Compression in Windows XP" href="http://support.microsoft.com/kb/307987" target="_blank">NTFS compression</a>, not even on a laptop with less than a GB free on the C: partition.&#160; Because if you do, you will get an error when installing <a title="Microsoft SQL Server 2005 Service Pack 3 download" href="http://www.microsoft.com/DOWNLOADS/details.aspx?familyid=AE7387C3-348C-4FAA-8AE5-949FDFBE59C4&amp;displaylang=en" target="_blank">SP3 for SQL Server 2005</a>.&#160; (I know, it&#8217;s not a best practice in terms of performance but for once that was really not what I was trying to optimize here. <img src='http://blog.hoegaerden.be/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> )</p>
<p>When going through the installation steps of the service pack, it will start upgrading your components.&#160; And suddenly you get the famous &quot;hotfix.exe has encountered a problem and needs to close&quot; popup.&#160; No explanation or any error description, just the usual popup to sent the error report to Microsoft.&#160; The application event log gave me more info:</p>
<blockquote><p>Product: Microsoft SQL Server 2005 &#8212; Error 28062. SQL Server Setup cannot install files to the compressed or encrypted folder: C:\Program Files\Microsoft SQL Server\. To continue, make sure that your installation directories are not compressed or encrypted, or specify a different directory, and then run SQL Server Setup again.</p>
</blockquote>
<p>The folder properties tell me that I will lose about 1.5 GB when I decompress my SQL Server folder.&#160; Luckily I now have 5 GB free (I compressed my whole Program Files folder about a month ago) so that should be okay&#8230;</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/image.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="370" alt="image" src="http://blog.hoegaerden.be/wp-content/uploads/image-thumb.png" width="284" border="0" /></a></p>
<p>In the meantime the Microsoft SQL Server 2005 Service Pack 3 Setup keeps on running, upgrading the other components.&#160; Only the Database Services component is now showing a failure status.&#160; When all other components are upgraded, you have the option to click the View Summary button in the Installation Complete screen.&#160; This also shows the error mentioned earlier.&#160; And of course you could also open the log file (C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG\Hotfix\SQL9_Hotfix_KB955706_sqlrun_sql.msp.log) for details.</p>
<p>Sidenote: my C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG\ folder currently contains 1.97 GB of log files.&#160; Another folder to clean out once the SP is fully installed.</p>
<p>After decompressing the folder I started setup again.&#160; It selected Database Services as the only remaining component for upgrade.&#160; This all went smoothly and my SQL 2005 is now happily reporting version 9.00.4035.00.</p>
<p>Microsoft is <a title="SQL Server Setup cannot install files to the compressed or encrypted folder" href="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=124538" target="_blank">aware of the issue and said in 2005 that it will consider adding the functionality in a future version</a>.&#160; Anyone who wants to try this out on 2008 once the first SP arrives?</p>
<p>If you want to know the inner details of why you should never compress your SQL Server data and log files in a production environment, check out <a title="Why you shouldn&#39;t compress SQL Server data and log files" href="http://blogs.msdn.com/khen1234/archive/2005/04/25/411852.aspx" target="_blank">this great article by Ken Henderson</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2009/01/18/do-not-compress-sql-server-folder/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Stop that MDX query!</title>
		<link>http://blog.hoegaerden.be/2009/01/09/stop-that-mdx-query/</link>
		<comments>http://blog.hoegaerden.be/2009/01/09/stop-that-mdx-query/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 19:12:12 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[Management Studio]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[MDX]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SSAS]]></category>
		<category><![CDATA[SSMS]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/2009/01/09/stop-that-mdx-query/</guid>
		<description><![CDATA[Have you ever had the situation that you wrote an MDX query to get some data out of a cube in Management Studio and executed it and waited and waited and the query never seems to end so you decide to cancel it so you click the red square button and then you wait and [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever had the situation that you wrote an MDX query to get some data out of a cube in Management Studio and executed it and waited and waited and the query never seems to end so you decide to cancel it so you click the red square button and then you wait and wait and wait some more and&#8230;.  Well, it&#8217;s a bug.</p>
<p>And the worst part of it, in my opinion, is that, even when you close your client connection to Analysis Services, the query keeps running on the server consuming CPU and memory and will finally take it down.</p>
<p>The good part is that Microsoft has fixed it in Cumulative Update 2 for Service Pack 2 for SQL Server 2005.  And now of course SP3 can be used as well to fix this situation.</p>
<p>The bug is described here: <a href="http://support.microsoft.com/kb/935832" target="_blank">http://support.microsoft.com/kb/935832</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2009/01/09/stop-that-mdx-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2005 SP3 is out!</title>
		<link>http://blog.hoegaerden.be/2008/12/19/sql-server-2005-sp3-is-out/</link>
		<comments>http://blog.hoegaerden.be/2008/12/19/sql-server-2005-sp3-is-out/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 19:43:37 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[SQL Server 2005]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/2008/12/19/sql-server-2005-sp3-is-out/</guid>
		<description><![CDATA[Microsoft has released an early Christmas present in the form of Service Pack 3 for SQL Server 2005.
The SP can be downloaded from the Download Center.  Same for the updated Books Online.
As I&#8217;m a fan of version numbers, SP3 upgrades your SQL Server to version 9.00.4035.
Besides all the fixes from the cumulative updates, the service [...]]]></description>
			<content:encoded><![CDATA[<p>Microsoft has released an early Christmas present in the form of Service Pack 3 for SQL Server 2005.</p>
<p>The SP can be downloaded from the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=ae7387c3-348c-4faa-8ae5-949fdfbe59c4&amp;DisplayLang=en" target="_blank">Download Center</a>.  Same for the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=BE6A2C5D-00DF-4220-B133-29C1E0B6585F&amp;displaylang=en" target="_blank">updated Books Online</a>.</p>
<p>As I&#8217;m a fan of version numbers, SP3 upgrades your SQL Server to version 9.00.4035.</p>
<p>Besides all the fixes from the cumulative updates, the service pack also contains some enhancements.  The one that caught my interest is the following:</p>
<blockquote><p>In SharePoint integrated mode, reports typically run slower than the same reports run in native mode. The main cause of this latency can be attributed to SharePoint object model calls that are made. In SQL Server 2005 SP3, the number of SharePoint object model calls that SQL Server 2005 Reporting Services (SSRS) makes are optimized. This optimization reduces some of the latency when you compare report performance with native mode.</p></blockquote>
<p>Now if you&#8217;ll excuse me, I&#8217;ve got some downloads to do <img src='http://blog.hoegaerden.be/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2008/12/19/sql-server-2005-sp3-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calling A Web Service From SQL Server 2005</title>
		<link>http://blog.hoegaerden.be/2008/11/11/calling-a-web-service-from-sql-server-2005/</link>
		<comments>http://blog.hoegaerden.be/2008/11/11/calling-a-web-service-from-sql-server-2005/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 13:09:09 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CLR]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/2008/11/11/calling-a-web-service-from-sql-server-2005/</guid>
		<description><![CDATA[This may not be your daily routine but in today&#8217;s world of interoperability and loosely-coupled systems you sometimes don&#8217;t have another option.&#160; Imagine a situation where a scheduled task (using SQL Agent) needs to get data from a web service or trigger some code through a web service.
In the following explanation I will show how [...]]]></description>
			<content:encoded><![CDATA[<p>This may not be your daily routine but in today&#8217;s world of interoperability and loosely-coupled systems you sometimes don&#8217;t have another option.&#160; Imagine a situation where a scheduled task (using SQL Agent) needs to get data from a web service or trigger some code through a web service.</p>
<p>In the following explanation I will show how to use SQL CLR (Common Language Runtime) Integration to get a weather report from a web service, or WS in short.</p>
<p>For this I am using a free web service: <a title="http://www.webservicex.net/globalweather.asmx" href="http://www.webservicex.net/globalweather.asmx">http://www.webservicex.net/globalweather.asmx</a>.&#160; Or not&#8230;&#160; Seems that the weather web service gods don&#8217;t like me, this WS has (temporarily?) stopped working after I completed the sample and part of this article.&#160; I haven&#8217;t found a replacement that can deliver global weather so we&#8217;ll have to do with US-only, delivered through this web service: <a title="http://ws.cdyne.com/WeatherWS/Weather.asmx" href="http://ws.cdyne.com/WeatherWS/Weather.asmx">http://ws.cdyne.com/WeatherWS/Weather.asmx</a>.</p>
<p>Now is a good time to warn you about the usage of external services.&#160; If you need your code to work all the time, make sure that you can trust the web services that you use.&#160; Otherwise you may just end up as I did, with a dead function&#8230;</p>
<p>Basic knowledge on building .NET assemblies and using SQL Server is required.</p>
<h2>The assembly</h2>
<p>Let&#8217;s start with creating our .NET assembly with the custom stored procedure.&#160; Using Visual Studio 2005, create a new Database Project:</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/database-project.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="Database_project" src="http://blog.hoegaerden.be/wp-content/uploads/database-project-thumb.png" width="468" height="339" /></a></p>
<p>Add a Web Reference to your project pointing to the .asmx mentioned earlier.</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/add-web-reference.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="Add_Web_Reference" src="http://blog.hoegaerden.be/wp-content/uploads/add-web-reference-thumb.png" width="462" height="277" /></a></p>
<p>Add a Stored Procedure to your project:</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/weathersp.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="WeatherSP" src="http://blog.hoegaerden.be/wp-content/uploads/weathersp-thumb.png" width="463" height="286" /></a></p>
<p>This class is going to contain the code to call the web service and return a result to the client.</p>
<p>Following code fetches the weather report for a given US Zip code.</p>
<p>&#160;</p>
<pre class="code"><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Data;
<span style="color: blue">using </span>System.Data.SqlClient;
<span style="color: blue">using </span>System.Data.SqlTypes;
<span style="color: blue">using </span>Microsoft.SqlServer.Server;
<span style="color: blue">using </span>MyStoredProcedures.com.cdyne.ws;

<span style="color: blue">public partial class </span><span style="color: #2b91af">StoredProcedures
</span>{
    [Microsoft.SqlServer.Server.<span style="color: #2b91af">SqlProcedure</span>]
    <span style="color: blue">public static void </span>WeatherSP(<span style="color: blue">string </span>zipCode)
    {
        <span style="color: #2b91af">Weather </span>myWeatherWS = <span style="color: blue">new </span><span style="color: #2b91af">Weather</span>();
        <span style="color: #2b91af">WeatherReturn </span>weatherResult = myWeatherWS.GetCityWeatherByZIP(zipCode);

        <span style="color: #2b91af">SqlMetaData</span>[] recordMetaData = <span style="color: blue">new </span><span style="color: #2b91af">SqlMetaData</span>[2];
        <span style="color: green">// layout of the records that we'll return
        </span>recordMetaData[0] = <span style="color: blue">new </span><span style="color: #2b91af">SqlMetaData</span>(<span style="color: #a31515">&quot;Description&quot;</span>, <span style="color: #2b91af">SqlDbType</span>.Char, 100);
        recordMetaData[1] = <span style="color: blue">new </span><span style="color: #2b91af">SqlMetaData</span>(<span style="color: #a31515">&quot;Value&quot;</span>, <span style="color: #2b91af">SqlDbType</span>.Char, 1000);

        <span style="color: green">// build a record based on the metadata
        </span><span style="color: #2b91af">SqlDataRecord </span>record = <span style="color: blue">new </span><span style="color: #2b91af">SqlDataRecord</span>(recordMetaData);

        <span style="color: green">// let's start sending result into the active pipe
        </span><span style="color: #2b91af">SqlContext</span>.Pipe.SendResultsStart(record);

        <span style="color: green">// one way of adding a new record to the pipe
        </span>record.SetString(0, <span style="color: #a31515">&quot;ResponseText&quot;</span>);
        record.SetString(1, weatherResult.ResponseText);
        <span style="color: #2b91af">SqlContext</span>.Pipe.SendResultsRow(record);

        <span style="color: green">// another way of adding a new record, using an array initializer
        </span>record.SetValues(<span style="color: blue">new </span><span style="color: #2b91af">String</span>[2] { <span style="color: #a31515">&quot;City&quot;</span>, weatherResult.City });
        <span style="color: #2b91af">SqlContext</span>.Pipe.SendResultsRow(record);

        record.SetValues(<span style="color: blue">new </span><span style="color: #2b91af">String</span>[2] { <span style="color: #a31515">&quot;State&quot;</span>, weatherResult.State });
        <span style="color: #2b91af">SqlContext</span>.Pipe.SendResultsRow(record);

        record.SetValues(<span style="color: blue">new </span><span style="color: #2b91af">String</span>[2] { <span style="color: #a31515">&quot;Description&quot;</span>, weatherResult.Description });
        <span style="color: #2b91af">SqlContext</span>.Pipe.SendResultsRow(record);

        record.SetValues(<span style="color: blue">new </span><span style="color: #2b91af">String</span>[2] { <span style="color: #a31515">&quot;Temperature&quot;</span>, weatherResult.Temperature });
        <span style="color: #2b91af">SqlContext</span>.Pipe.SendResultsRow(record);

        record.SetValues(<span style="color: blue">new </span><span style="color: #2b91af">String</span>[2] { <span style="color: #a31515">&quot;Timestamp&quot;</span>, <span style="color: #2b91af">DateTime</span>.Now.ToString() });
        <span style="color: #2b91af">SqlContext</span>.Pipe.SendResultsRow(record);

        <span style="color: green">// finished sending result
        </span><span style="color: #2b91af">SqlContext</span>.Pipe.SendResultsEnd();
    }

};</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>In the code above you can see that the stored procedure has a parameter called zipCode.&#160; This incoming value is passed to the web service call.</p>
<p>Our result consists of several records, each record containing 2 string fields.</p>
<p>The web service that we&#8217;ve used returns an object of type WeatherResult.&#160; This makes it easy for us to read the result.&#160; The WS that I used initially didn&#8217;t return an object but an XML string.&#160; In that case you can use the XmlDocument.LoadXml from the System.Xml namespace to get an XmlDocument.&#160; Then use the SelectSingleNode method to get to the details, for instance myXmlDoc.SelectSingleNode(&quot;//Temperature&quot;).InnerText would return the value for the Temperature node.</p>
<p>And this is what it looks like when our stored procedure gets called from the Management Studio:</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/weathersp-ssms-result.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="WeatherSP_SSMS_result" src="http://blog.hoegaerden.be/wp-content/uploads/weathersp-ssms-result-thumb.png" width="234" height="237" /></a></p>
<h3>Building the assembly</h3>
<p>Before we build our assembly there are a couple of project settings that need modification.</p>
<p>Here we ask Visual Studio to also generate an assembly containing the XML Serializers.&#160; This is needed because our code is calling a web service and code running in SQL Server is not allowed to use the serializers that are normally generated dynamically.</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/project-properties-build-tab.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="Project_properties_Build_tab" src="http://blog.hoegaerden.be/wp-content/uploads/project-properties-build-tab-thumb.png" width="489" height="434" /></a></p>
<p>Another setting that we need to change is the Permission Level.&#160; This is also required because our code is calling a web service, hence external.</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/project-properties-database-tab.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="Project_properties_Database_tab" src="http://blog.hoegaerden.be/wp-content/uploads/project-properties-database-tab-thumb.png" width="490" height="218" /></a></p>
<h2>Server and Database Settings</h2>
<p>Now that we&#8217;ve covered the actual development of the stored procedure we would like to install it on our database server.&#160; This requires us to modify some settings on the server and database.&#160; If you are not the DBA of the server and you are in the luxurious situation that such a person exists, please verify with him/her if you are allowed to modify these settings.</p>
<h3>Enabling CLR Integration</h3>
<p>By default SQL Server does not allow CLR Integration.&#160; This setting can be easily modified with the following script:</p>
<pre class="code"><span style="color: blue">exec </span><span style="color: maroon">sp_configure </span><span style="color: red">'clr enabled'</span><span style="color: gray">, </span><span style="color: red">'1'</span><span style="color: gray">;
</span><span style="color: blue">reconfigure</span><span style="color: gray">;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<div>&#160;</div>
<h3>Our database we trust</h3>
<p>As our stored procedure needs external access permission, we need to create the assembly with external access (as shown in next chapter).&#160; To get this to work we need to convince SQL Server that our database can be trusted: (I&#8217;ve used AdventureWorks in this article but this can be any existing database)</p>
<pre class="code"><span style="color: blue">ALTER DATABASE </span>AdventureWorks <span style="color: blue">SET TRUSTWORTHY ON</span><span style="color: gray">;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<div>&#160;</div>
<h3>Owner needs external access</h3>
<div>To be allowed to create an assembly with external access, the database owner needs to have EXTERNAL ACCESS ASSEMBLY permission.&#160; If that&#8217;s not the case you will see the following error when trying to create the assembly:</div>
<div>&#160;</div>
<blockquote>
<div><span style="color: #ff0000">Msg 10327, Level 14, State 1, Line 1 CREATE ASSEMBLY for assembly &#8216;MyStoredProcedures&#8217; failed because assembly &#8216;MyStoredProcedures&#8217; is not authorized for PERMISSION_SET = EXTERNAL_ACCESS. The assembly is authorized when either of the following is true: the database owner (DBO) has EXTERNAL ACCESS ASSEMBLY permission and the database has the TRUSTWORTHY database property on; or the assembly is signed with a certificate or an asymmetric key that has a corresponding login with EXTERNAL ACCESS ASSEMBLY permission. If you have restored or attached this database, make sure the database owner is mapped to the correct login on this server. If not, use sp_changedbowner to fix the problem.</span></div>
</blockquote>
<div>&#160;</div>
<div>So to avoid this error make sure that your DB owner has sufficient permissions.&#160; The following script makes sa the owner of the active database:</div>
<div>&#160;</div>
<div>
<pre class="code"><span style="color: blue">EXEC </span><span style="color: maroon">sp_changedbowner </span><span style="color: red">'sa'</span><span style="color: gray">, </span>false<span style="color: gray">;</span></pre>
<p>  <a href="http://11011.net/software/vspaste"></a></div>
<h2>Installing the Stored Procedure</h2>
<p>We&#8217;re almost there, all that remains to be done is to tell SQL Server where our stored procedure can be found and that it actually exists.&#160; Assemblies, just like stored procedures, live in a database (AdventureWorks in our case).&#160; In Management Studio you can see your assemblies in the Object explorer under the Programmability node of your database:</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/ssms-assemblies.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="SSMS_assemblies" src="http://blog.hoegaerden.be/wp-content/uploads/ssms-assemblies-thumb.png" width="208" height="203" /></a></p>
<h3>Adding the assemblies</h3>
<p>Following script adds the two assemblies that we&#8217;ve created earlier to your database.&#160; An assembly is given a name, like MyStoredProcedures.&#160; Here you can finally see the EXTERNAL_ACCESS permission that we need for our web service call.</p>
<pre class="code"><span style="color: blue">CREATE ASSEMBLY </span>MyStoredProcedures
<span style="color: blue">FROM </span><span style="color: red">'D:\vvr\techtests\dotnet\MyStoredProcedures\MyStoredProcedures\bin\Debug\MyStoredProcedures.dll'
</span><span style="color: blue">WITH PERMISSION_SET </span><span style="color: gray">= </span><span style="color: blue">EXTERNAL_ACCESS</span><span style="color: gray">;
</span><span style="color: blue">GO

CREATE ASSEMBLY </span>MyXmlSerializers
<span style="color: blue">FROM
</span><span style="color: red">'D:\vvr\techtests\dotnet\MyStoredProcedures\MyStoredProcedures\bin\Debug\MyStoredProcedures.XmlSerializers.dll'
</span><span style="color: blue">WITH PERMISSION_SET </span><span style="color: gray">= </span><span style="color: blue">EXTERNAL_ACCESS</span><span style="color: gray">;
</span><span style="color: blue">GO</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<div>&#160;</div>
<h3>Adding our stored procedure</h3>
<p>Last step is to create our stored procedure.&#160; We tell SQL Server that it can be found in the MyStoredProcedures assembly, in the class StoredProcedures and that the method is called WeatherSP.&#160; We have one parameter of type string in our method definition, which translates to nvarchar in the stored procedure.&#160; A length of 10 is more than enough for our ZIP code.</p>
<pre class="code"><span style="color: blue">CREATE PROCEDURE </span>WeatherSP
    @zipCode <span style="color: blue">nvarchar</span><span style="color: gray">(</span>10<span style="color: gray">)
</span><span style="color: blue">AS EXTERNAL </span>NAME MyStoredProcedures<span style="color: gray">.</span>StoredProcedures<span style="color: gray">.</span>WeatherSP<span style="color: gray">;
</span><span style="color: blue">GO</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<div>&#160;</div>
<h2>Configuring the Stored Procedure</h2>
<p>In some (most?) cases we don&#8217;t want to hard-code connection details. In this case it means the path to the web service. Imagine a situation where you are consuming a web service that you&#8217;ve developed yourself, or another team in your company. And the web service is running in several environments: development, acceptance, production. Of course we don&#8217;t want to change our code and recompile each time we need to deploy to a different environment. So we need a way to configure the web service location.</p>
<p>The answer here lies in the sqlservr.exe.config file. This is a file like any other .config file, with a possible content like this:</p>
<pre class="code"><span style="color: blue">&lt;?</span><span style="color: #a31515">xml </span><span style="color: red">version</span><span style="color: blue">=</span>&quot;<span style="color: blue">1.0</span>&quot; <span style="color: red">encoding</span><span style="color: blue">=</span>&quot;<span style="color: blue">utf-8</span>&quot; <span style="color: blue">?&gt;
&lt;</span><span style="color: #a31515">configuration</span><span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">appSettings</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">add </span><span style="color: red">key</span><span style="color: blue">=</span>&quot;<span style="color: blue">MyWebService</span>&quot; <span style="color: red">value</span><span style="color: blue">=</span>&quot;<span style="color: blue">http://MyWebServiceServer:MyWSPort/PathTo/MyWebService.asmx</span>&quot; <span style="color: blue">/&gt;
  &lt;/</span><span style="color: #a31515">appSettings</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">configuration</span><span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<div>&#160;</div>
<p>This file needs to be put in the same folder as your sqlservr.exe that&#8217;s running your SQL Server instance.&#160; By default this path is C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\.&#160; When you restart your SQL Server instance while this file is in that folder, SQL Server will pick up any configuration settings from that file.&#160; These can then be accessed from your custom stored procedure in this way:</p>
<pre class="code"><span style="color: green">/* The following call is made in order to workaround an &quot;anomaly&quot;
   * where reading an appSettings key value results in the error:
   * &quot;The value of the property 'key' cannot be parsed.
   * The error is: Request failed. (sqlservr.exe.Config line X)&quot;
   *
   * So, just a call to another section alleviates the issue.
   * This error only occurs on the first call to an assembly after
   * it's been loaded by the sqlservr.exe
   */
</span><span style="color: blue">int </span>firstcall = ConfigurationManager.ConnectionStrings.Count;

MyWebService myWS = <span style="color: blue">new </span>MyWebService();
myWS.Url = ConfigurationManager.AppSettings[<span style="color: #a31515">&quot;MyWebService&quot;</span>];
myWS.MyWebMethod();</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<div>&#160;</div>
<p>That’s it, that’s all it takes.&#160; It’s not that difficult, once you know it, right? <img src='http://blog.hoegaerden.be/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Have fun!</p>
<p>Valentino.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2008/11/11/calling-a-web-service-from-sql-server-2005/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>KB948109 fails with errorcode 0&#215;80070643</title>
		<link>http://blog.hoegaerden.be/2008/08/20/kb948109-fails-with-errorcode-0x80070643/</link>
		<comments>http://blog.hoegaerden.be/2008/08/20/kb948109-fails-with-errorcode-0x80070643/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 20:20:20 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/?p=44</guid>
		<description><![CDATA[Having trouble getting KB948109 installed?  I did.  It was caused by some SQL Server services which I never use and had put to Disabled.  Put them to Manual or Automatic.  Then the update will install fine.
Here&#8217;s the full error description from the System Event Log:
Installatiefout: de volgende update kan niet worden geïnstalleerd, foutcode 0&#215;80070643: Security [...]]]></description>
			<content:encoded><![CDATA[<p>Having trouble getting KB948109 installed?  I did.  It was caused by some SQL Server services which I never use and had put to Disabled.  Put them to Manual or Automatic.  Then the update will install fine.</p>
<p>Here&#8217;s the full error description from the System Event Log:</p>
<blockquote><p>Installatiefout: de volgende update kan niet worden geïnstalleerd, foutcode 0&#215;80070643: Security Update for SQL Server 2005 Service Pack 2 (KB948109).</p></blockquote>
<p>This was on my home PC, running XP Home Edition NL (which explains the Dutch in the error msg) and SQL Server 2005 Express SP2.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2008/08/20/kb948109-fails-with-errorcode-0x80070643/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DIY: Alternative Reporting Services client</title>
		<link>http://blog.hoegaerden.be/2008/08/03/diy-alternative-reporting-services-client/</link>
		<comments>http://blog.hoegaerden.be/2008/08/03/diy-alternative-reporting-services-client/#comments</comments>
		<pubDate>Sun, 03 Aug 2008 13:50:03 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/2008/08/03/diy-alternative-reporting-services-client/</guid>
		<description><![CDATA[The other day I was looking for an alternative Reporting Services client, as an extra client besides the web-based Report Manager. As I couldn&#8217;t really find one I thought &#8220;how difficult could it be to write one myself?&#8221;.
And indeed, with the ReportViewer control in Visual Studio 2005 it&#8217;s really no big deal. All you need [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I was looking for an alternative Reporting Services client, as an extra client besides the web-based Report Manager. As I couldn&#8217;t really find one I thought &#8220;how difficult could it be to write one myself?&#8221;.</p>
<p>And indeed, with the ReportViewer control in Visual Studio 2005 it&#8217;s really no big deal. All you need to do is drag the control onto a form, tell it that you want to load a remote report, configure the ReportServer so that it knows where to look for reports and the ReportPath so that it knows what report to load. Then call the RefreshReport() method to load the report.</p>
<p>When configuring the ReportPath, pay attention to the mandatory leading slash.</p>
<div>
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060;">   1:</span> reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   2:</span> reportViewer1.ServerReport.ReportServerUrl = <span style="color: #0000ff;">new</span> Uri(<span style="color: #006080;">"http://localhost/reportserver"</span>);</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060;">   3:</span> reportViewer1.ServerReport.ReportPath = <span style="color: #006080;">"/My Reports/ReportName"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   4:</span> <span style="color: #008000;">// load report</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060;">   5:</span> reportViewer1.RefreshReport();</pre>
</div>
</div>
<p>The C# code snippet above is loading a report called ReportName, located on the local report server in a folder called My Reports.</p>
<p><strong>Update: how to browse the reports on the server</strong></p>
<p>Microsoft has provided an interesting sample called RSExplorer as part of the <a href="http://www.codeplex.com/SqlServerSamples/Release/ProjectReleases.aspx?ReleaseId=4000" target="_blank">SQL Server samples, located at CodePlex</a>.  Once you&#8217;ve installed the samples you can find RSExplorer in C:\Program Files\Microsoft SQL Server\90\Samples\Reporting Services\Application Samples\RSExplorer Sample\, if you chose to install to the default folder.</p>
<p>The sample shows how to use the Reporting Services web service to populate a WinForms ListView with a list of folders and reports, and even how to do some basic management tasks like creating a folder or editing a report description.</p>
<p>When you double-click a report it will open in a popup window.  What I do find funny in this sample is that the popup window, called ReportViewer, does not use the ReportViewer control.  It uses a WebBrowser control  instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2008/08/03/diy-alternative-reporting-services-client/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQL Server 2005 Reporting Services: the black background issue</title>
		<link>http://blog.hoegaerden.be/2008/07/27/sql-server-2005-reporting-services-the-black-background-issue/</link>
		<comments>http://blog.hoegaerden.be/2008/07/27/sql-server-2005-reporting-services-the-black-background-issue/#comments</comments>
		<pubDate>Sun, 27 Jul 2008 10:12:16 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/2008/07/27/sql-server-2005-reporting-services-the-black-background-issue/</guid>
		<description><![CDATA[Recently I came across a bug that was introduced in the Reporting Services part of SQL Server 2005 SP2.  When previewing the &#8220;Print Layout&#8221; of the report it would show like this:

The by default Transparent background would show as black instead of white.  Obviously this is not very convenient, especially when the text [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I came across a bug that was introduced in the Reporting Services part of SQL Server 2005 SP2.  When previewing the &#8220;Print Layout&#8221; of the report it would show like this:</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/ssrs-preview-printlayout-bug.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://blog.hoegaerden.be/wp-content/uploads/ssrs-preview-printlayout-bug-thumb.png" border="0" alt="SSRS_preview_printlayout_bug" width="244" height="114" /></a></p>
<p>The by default Transparent background would show as black instead of white.  Obviously this is not very convenient, especially when the text is also black.</p>
<p>Luckily Microsoft was already aware of this issue, its KB is located <a title="http://support.microsoft.com/kb/935436" href="http://support.microsoft.com/kb/935436">here</a>.</p>
<p>I managed to solve the problem by installing Cumulative Update 1 (build 3161), which can be requested for download through the following Microsoft page: <a title="http://support.microsoft.com/kb/935356/en-us" href="http://support.microsoft.com/kb/935356/en-us">http://support.microsoft.com/kb/935356/en-us</a>.</p>
<p>If you don&#8217;t like installing CUs, you could wait until SP3 ships in Q3 this year (this info comes from several sources, just do a search on &#8220;sql server 2005 SP3&#8243;).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2008/07/27/sql-server-2005-reporting-services-the-black-background-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
