<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Arcane Code &#187; SQL Server</title>
	<atom:link href="http://arcanecode.com/tag/sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://arcanecode.com</link>
	<description>Making Microsoft .Net Development Magical</description>
	<lastBuildDate>Sat, 26 May 2012 09:32:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='arcanecode.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Arcane Code &#187; SQL Server</title>
		<link>http://arcanecode.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://arcanecode.com/osd.xml" title="Arcane Code" />
	<atom:link rel='hub' href='http://arcanecode.com/?pushpress=hub'/>
		<item>
		<title>SQL Saturday #111&#8211;Atlanta</title>
		<link>http://arcanecode.com/2012/04/13/sql-saturday-111atlanta/</link>
		<comments>http://arcanecode.com/2012/04/13/sql-saturday-111atlanta/#comments</comments>
		<pubDate>Sat, 14 Apr 2012 05:13:54 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[Data Warehousing]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Reporting Services]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">https://arcanecode.wordpress.com/?p=2139</guid>
		<description><![CDATA[Today I’m presenting not one but two sessions at the Atlanta SQL Saturday. I wanted to provide copies of my slide decks here. Configuring SQL Server 2012 Reporting Services The Decoder Ring to Data Warehousing / Business Intelligence Hope you enjoyed the sessions, and thanks for coming.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=2139&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I’m presenting not one but two sessions at the Atlanta SQL Saturday. I wanted to provide copies of my slide decks here. </p>
<p><a href="http://arcanecode.files.wordpress.com/2012/04/configuring-ssrs.pdf" target="_blank">Configuring SQL Server 2012 Reporting Services</a></p>
<p><a href="http://arcanecode.files.wordpress.com/2012/04/introtodatawarehousing_pw.pdf" target="_blank">The Decoder Ring to Data Warehousing / Business Intelligence</a></p>
<p>Hope you enjoyed the sessions, and thanks for coming. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/2139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=2139&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2012/04/13/sql-saturday-111atlanta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>
	</item>
		<item>
		<title>SharePoint BI (Business Intelligence) Training Resources</title>
		<link>http://arcanecode.com/2012/03/29/sharepoint-bi-business-intelligence-training-resources/</link>
		<comments>http://arcanecode.com/2012/03/29/sharepoint-bi-business-intelligence-training-resources/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 06:45:00 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[BI]]></category>
		<category><![CDATA[Sharepoint]]></category>

		<guid isPermaLink="false">https://arcanecode.wordpress.com/?p=2122</guid>
		<description><![CDATA[SharePoint is a huge topic unto itself, so I wanted to provide some links that focus on learning how to use SharePoint in the context of Business Intelligence.&#160; A quick disclaimer, some of the links below are by co-workers or other people I have an affiliation with, financial or otherwise. That’s because I’m lucky enough [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=2122&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>SharePoint is a huge topic unto itself, so I wanted to provide some links that focus on learning how to use SharePoint in the context of Business Intelligence.&#160; </p>
<p>A quick disclaimer, some of the links below are by co-workers or other people I have an affiliation with, financial or otherwise. That’s because I’m lucky enough to work with some of the best people in the field. Also, in the case of the books I’ve linked to the Kindle version where possible, mostly because I’m a Kindle junkie. There are paper versions of the books, and you are free to buy from your favorite retailer. </p>
<h2>Books</h2>
<p><a href="http://www.amazon.com/SharePoint-Business-Intelligence-24-Hour-Programmer/dp/111802642X/ref=sr_1_3?ie=UTF8&amp;qid=1332883525&amp;sr=8-3" target="_blank">SharePoint 2010 Business Intelligence 24 hour Trainer</a> – This is a really cool book, in that it’s not just a book. It comes with a DVD loaded with video lessons on how to use the various tools in SharePoint for doing BI. This is the first book to buy if you are new to doing BI in SharePoint. </p>
<p><a href="http://www.amazon.com/Business-Intelligence-Microsoft%C2%AE-SharePoint%C2%AE-ebook/dp/B0050FAHLW/ref=sr_1_5?ie=UTF8&amp;qid=1332883525&amp;sr=8-5" target="_blank">Business Intelligence in Microsoft SharePoint 2010</a> – This is a great book which provides an introduction to all of the BI Services available within SharePoint 2010. </p>
<p><a href="http://www.amazon.com/Microsoft-SharePoint-Intelligence-Unleashed-ebook/dp/B00503D22U/ref=kinw_dp_ke?ie=UTF8&amp;m=AG56TWVU5XWC2" target="_blank">Microsoft SharePoint 2010 Business Intelligence Unleashed</a> – Like most of the books in the “Unleashed” series, this takes a much deeper dive into the tools than the previous two books. A good choice once you are ready to move beyond the beginner stage.</p>
<h2>Blogs</h2>
<p>There aren’t many blogs that focus solely on SharePoint for BI, so I’ve picked out two sites that have a lot of SharePoint for BI content on them. </p>
<p><a href="http://blog.datainspirations.com/" target="_blank">Data Inspirations</a> -&#160; This blog focuses on all aspects of BI, one of the lead bloggers is Stacia Misner, co-author of the BI in Microsoft SharePoint 2010 book listed above. </p>
<p><a href="http://bidn.com/" target="_blank">BIDN</a> – Many experts in the BI field, myself included, contribute to the Business Intelligence Developer Network. Here you’ll find a wide variety of topics in the BI field, including many on SharePoint BI. </p>
<h2>Videos</h2>
<p><a href="http://pragmaticworks.com/Resources/webinars/Default.aspx" target="_blank">Pragmatic Works Webinars</a> – On our website we have a big catalog of past webinars (all of which are free to watch), many of which focus on PowerPivot. </p>
<p><a href="http://www.pluralsight-training.net/microsoft/" target="_blank">Pluralsight</a> – Pluralsight has an extensive catalog of other courses you can pick from. It’s subscription bases so there is a modest fee (starts at $29 US per month last I checked) but well worth it for the training you can get. There’s also a free trial. </p>
<p>For a quick link direct to this post, you can use <a href="http://bit.ly/arcanespbi">http://bit.ly/arcanespbi</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/2122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/2122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/2122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/2122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/2122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/2122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/2122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/2122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/2122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/2122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/2122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/2122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/2122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/2122/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=2122&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2012/03/29/sharepoint-bi-business-intelligence-training-resources/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>
	</item>
		<item>
		<title>PowerPivot Training Resources</title>
		<link>http://arcanecode.com/2012/03/28/powerpivot-training-resources/</link>
		<comments>http://arcanecode.com/2012/03/28/powerpivot-training-resources/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 06:17:00 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[PowerPivot]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">https://arcanecode.wordpress.com/?p=2120</guid>
		<description><![CDATA[I’ve been asked to provide links to some useful resources for learning about PowerPivot. Below are a list of my favorite blogs, books, and other sites to learn from. A quick disclaimer, some of the links below are by co-workers or other people I have an affiliation with, financial or otherwise. That’s because I’m lucky [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=2120&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I’ve been asked to provide links to some useful resources for learning about PowerPivot. Below are a list of my favorite blogs, books, and other sites to learn from. </p>
<p>A quick disclaimer, some of the links below are by co-workers or other people I have an affiliation with, financial or otherwise. That’s because I’m lucky enough to work with some of the best people in the field. Also, in the case of the books I’ve linked to the Kindle version where possible, mostly because I’m a Kindle junkie. There are paper versions of the books, and you are free to buy from your favorite retailer. </p>
<h2>Books</h2>
<p><a href="http://www.amazon.com/Professional-PowerPivot-SharePoint-Programmer-ebook/dp/B003O86FBI/ref=kinw_dp_ke?ie=UTF8&amp;m=AG56TWVU5XWC2" target="_blank">Professional Microsoft PowerPivot for Excel and SharePoint</a> – This book covers all aspects of PowerPivot, from using it to installing it to configuration. Everything you want to know in one volume. I wouldn’t particularly call this a beginners book however, it assumes you are competent in BI, Excel, and SharePoint. </p>
<p><a href="http://www.amazon.com/Microsoft%C2%AE-PowerPivot-Excel%C2%AE-2010-ebook/dp/B004D4YIAW/ref=pd_sim_kstore_2?ie=UTF8&amp;m=AG56TWVU5XWC2" target="_blank">Microsoft PowerPivot for Excel 2010: Give Your Data Meaning</a> – This is a good first book to get, it goes deeply into the use of PowerPivot within Excel. </p>
<p><a href="http://www.amazon.com/Practical-PowerPivot-Formulas-Excel-ebook/dp/B0041842TC/ref=pd_sim_kstore_3?ie=UTF8&amp;m=AG56TWVU5XWC2" target="_blank">Practical PowerPivot and DAX Formulas for Excel 2010</a> – Once you are comfortable with PowerPivot, you’ll want to learn more about DAX, Data Analysis eXpressions, the set of functions used to do advanced calculations and aggregations in PowerPivot. I’m a big fan of the way the author, Art Tennick does his books. It’s the Problem – Solution approach, where he demonstrates a common problem then shows one or more ways to solve it. Art also has books on MDX and DMX you should check out. </p>
<h2>Blogs</h2>
<p><a href="http://www.powerpivotpro.com/" target="_blank">PowerPivot Pro</a> – Probably one of the best blogs around, Rob and Kasper provide excellent content. </p>
<p><a href="http://dennyglee.com/" target="_blank">Denny Lee’s Blog</a> – Denny works for Microsoft and is part of the PowerPivot team. He provides some really great insights, and is co-author of the Professional Microsoft PowerPivot for Excel and SharePoint book above. </p>
<p><a href="http://powerpivot-info.com/" target="_blank">PowerPivot Info</a> – Not so much a blog but a blog aggregator, this site brings the best PowerPivot content on the web to the forefront. </p>
<h2>Videos</h2>
<p><a href="http://pragmaticworks.com/Resources/webinars/Default.aspx" target="_blank">Pragmatic Works Webinars</a> – On our website we have a big catalog of past webinars (all of which are free to watch), many of which focus on PowerPivot. </p>
<p><a href="http://www.pluralsight-training.net/microsoft/" target="_blank">Pluralsight</a> – A little shameless self promotion here. I did a complete course on PowerPivot for Pluralsight. This includes both using PowerPivot from Excel and managing PowerPivot within SharePoint. In addition, Pluralsight has an extensive catalog of other courses you can pick from. It’s subscription bases so there is a modest fee (starts at $29 US per month last I checked) but well worth it for the training you can get. There’s also a free trial. </p>
<p>For a quick link direct to this post, you can use <a href="http://bit.ly/arcanepivot">http://bit.ly/arcanepivot</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/2120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/2120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/2120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/2120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/2120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/2120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/2120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/2120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/2120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/2120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/2120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/2120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/2120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/2120/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=2120&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2012/03/28/powerpivot-training-resources/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>
	</item>
		<item>
		<title>Using TFS2010 with Visual Studio / BIDS 2008 and SQL Server Management Studio</title>
		<link>http://arcanecode.com/2012/02/14/using-tfs2010-with-visual-studio-bids-2008-and-sql-server-management-studio/</link>
		<comments>http://arcanecode.com/2012/02/14/using-tfs2010-with-visual-studio-bids-2008-and-sql-server-management-studio/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 22:52:00 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[BIDS]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server Analysis Services]]></category>
		<category><![CDATA[SQL Server Integration Services]]></category>
		<category><![CDATA[SQL Server Reporting Services]]></category>
		<category><![CDATA[SSAS]]></category>
		<category><![CDATA[SSIS]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[Team Foundation Server]]></category>
		<category><![CDATA[TFS]]></category>
		<category><![CDATA[Visual Studio 2008]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[SSMS]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">https://arcanecode.wordpress.com/?p=2112</guid>
		<description><![CDATA[When I come to a customer site, I often have to help them get setup with TFS (Team Foundation Server) 2010, Microsoft’s source code control / ALM (application lifecycle management) system. This is so they can work with their BIDS (Business Intelligence Developer Studio) projects as a team, giving the added benefit of source code [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=2112&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When I come to a customer site, I often have to help them get setup with TFS (Team Foundation Server) 2010, Microsoft’s source code control / ALM (application lifecycle management) system. This is so they can work with their BIDS (Business Intelligence Developer Studio) projects as a team, giving the added benefit of source code control. I’ve had to do this often enough I wanted to record the steps for my own use, and hopefully others too. </p>
<h3>Installing the TFS 2010 tools for Visual Studio / BIDS 2008</h3>
<p>First off, thanks to Derek Miller for covering most of the steps involved in his blog post <a title="http://derekjmiller62.wordpress.com/2010/10/19/using-tfs-2010-with-bids-2008/" href="http://derekjmiller62.wordpress.com/2010/10/19/using-tfs-2010-with-bids-2008/">http://derekjmiller62.wordpress.com/2010/10/19/using-tfs-2010-with-bids-2008/</a>. I won’t go into the detail he did, but will summarize into these basic steps.</p>
<p>1. If you haven’t installed <a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=10986" target="_blank">Visual Studio 2008 Service Pack 1</a>, do so by downloading it and installing. </p>
<p>2. Next, you will need to install the <a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=16338" target="_blank">Visual Studio 2008 Team Explorer</a>. </p>
<p>3. After installing Team Explorer, you will have to go back and reinstall VS SP1 (from step 1). <em>Don’t skip this step!</em> Team explorer has some older components that overwrite the SP1 components, and you will have reinstall them. </p>
<p>Now this next part I really haven’t seen anywhere else and was a real pain to find, and thus is the main reason for this post. During the SP1 install, we often see “Visual Studio SP1 Installation Failed”. Checking the error log, buried deep you will find “Returning IDOK. INSTALLMESSAGE_ERROR [Error 2902. An internal error has occurred. …” </p>
<p>When you see this, go to your Control Panel, and then to Add Remove Programs. Look for a program called “Microsoft Visual Studio Web Authoring Component” and uninstall it. This is actually installed as part of the Office suite, and you don’t really need it since you likely have much more powerful web authoring tools, or since you are doing BI development won’t be doing an web development in Microsoft Office. </p>
<p>After uninstalling it, SP1 should then install, and you are ready for step 4. </p>
<p>4. Install the <a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=10834" target="_blank">Visual Studio Team System 2008 SP1 Forward Compatibility Update for Team Foundation Server 2010</a>. That probably took you longer to read than it actually will to install. After installing, it may prompt you to reboot. Even if it doesn’t ask you should reboot anyway, we’ve seen a few times when we weren’t able to connect until we rebooted. </p>
<p>After that you should be able to go into Visual Studio and go to Tools, Connect to Team Foundation Server. If you still have problems connecting, I will refer you to Derek’s post where he describes some registry entries you can try. So far we haven’t found them necessary, but you may. </p>
<h3>Installing the TFS 2010 Tools</h3>
<p>Note that there is one big limitation to using TFS 2010 with VS2008. You can connect to a TFS site and upload your solutions and projects, but you can’t create a new team site with VS2008. To do so, you will need the VS2010 shell with the TFS components, a free <a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=329" target="_blank">download</a>. </p>
<h3>Installing TFS 2010 for SQL Server Management Studio (SSMS)</h3>
<p>Now that you have BIDS all setup to work with TFS, it only makes sense to make your SQL Server Management Studio (SSMS) also work with TFS. Joseph Jun has a great <a href="http://blog.discountasp.net/using-team-foundation-server-2010-source-control-from-sql-server-management-studio/" target="_blank">blog post</a> that goes into all the nitty gritty of how to do this. The short version though, is after you install the TFS 2010 tools in the step above (and they are a prerequisite) you need to install the <a href="http://visualstudiogallery.msdn.microsoft.com/bce06506-be38-47a1-9f29-d3937d3d88d6/" target="_blank">Team Foundation Server MSSCCI Provider 2010</a>. </p>
<p>After the install, you should see a new Source Control menu option under the File menu in SSMS. From here you can launch the TFS 2010 management shell or open an existing SSMS project / solution. If you have a solution you need to add, simply right click on the solution in the Solution Explorer window and pick Add to Source Control. </p>
<h3>Visual Studio Database Projects</h3>
<p>Note that if you are using Visual Studio Database Projects, any SQL Server 2008R2 development must be done in Visual Studio 2010. VS2010 is already setup to talk to TFS 2010. If you are using VS 2008 database projects to build a SQL Server 2008 (non-R2) database, then with the steps above you should be good to go for checking in your database project into TFS. </p>
<h3>And away we go!</h3>
<p>And with that you should be setup to manage your BI Development in Team Foundation Server 2010. It’s a lot of work, but well worth the effort. Using TFS will let your BI staff work as a team to develop projects. Additionally you have the benefit of source code control, something invaluable in the case of package corruptions or needing to track history. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/2112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/2112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/2112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/2112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/2112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/2112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/2112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/2112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/2112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/2112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/2112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/2112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/2112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/2112/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=2112&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2012/02/14/using-tfs2010-with-visual-studio-bids-2008-and-sql-server-management-studio/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>
	</item>
		<item>
		<title>Task Factory&#8211;File Properties Task</title>
		<link>http://arcanecode.com/2011/07/18/task-factoryfile-properties-task/</link>
		<comments>http://arcanecode.com/2011/07/18/task-factoryfile-properties-task/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 04:11:22 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[Pragmatic Works]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server Integration Services]]></category>
		<category><![CDATA[SSIS]]></category>
		<category><![CDATA[Task Factory]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Integraion Services]]></category>

		<guid isPermaLink="false">https://arcanecode.wordpress.com/2011/07/18/task-factoryfile-properties-task/</guid>
		<description><![CDATA[My last video on the Task Factory Compression Task was well received, so I thought I’d build on it with a video on the File Properties Task. It’s a cool little tool that will grab any of the various attributes associated with a file. If you want to see more about Task Factory, you can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=2032&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://arcanecode.com/2011/07/16/task-factorytf-compression/" target="_blank">last video</a> on the Task Factory Compression Task was well received, so I thought I’d build on it with a video on the File Properties Task. It’s a cool little tool that will grab any of the various attributes associated with a file. If you want to see more about Task Factory, you can head on over to my employers website, <a href="http://pragmaticworks.com/" target="_blank">Pragmatic Works.com</a></p>
<span style="text-align:center; display: block;"><a href="http://arcanecode.com/2011/07/18/task-factoryfile-properties-task/"><img src="http://img.youtube.com/vi/FtFgVlLwB0s/2.jpg" alt="" /></a></span>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/2032/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/2032/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/2032/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/2032/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/2032/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/2032/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/2032/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/2032/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/2032/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/2032/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/2032/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/2032/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/2032/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/2032/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=2032&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2011/07/18/task-factoryfile-properties-task/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>
	</item>
		<item>
		<title>Data Dude Webinar for Pragmatic Works</title>
		<link>http://arcanecode.com/2011/06/07/data-dude-webinar-for-pragmatic-works/</link>
		<comments>http://arcanecode.com/2011/06/07/data-dude-webinar-for-pragmatic-works/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 03:35:20 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[Data Dude]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio Database Projects]]></category>

		<guid isPermaLink="false">https://arcanecode.wordpress.com/2011/06/07/data-dude-webinar-for-pragmatic-works/</guid>
		<description><![CDATA[Just wanted to let everyone know I’ll be doing my first webinar for Pragmatic Works this Thursday, June 9th 2011. It will be at 11 am Eastern time. I’ll be doing an introduction to “Data Dude”, Visual Studio Database Projects. We’ll cover such things as generating a project from an existing database, using the safe [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1998&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just wanted to let everyone know I’ll be doing my first webinar for Pragmatic Works this Thursday, June 9th 2011. It will be at 11 am Eastern time. </p>
<p>I’ll be doing an introduction to “Data Dude”, Visual Studio Database Projects. We’ll cover such things as generating a project from an existing database, using the safe refactoring tools, and generating sample data. There’s no cost, and I hope you can join us live so I can answer any of your questions. If you can’t, then we’ll be recording the session for later viewing. To register, jump on over to our website and register:</p>
<p><a title="http://pragmaticworks.com/Resources/webinars/Default.aspx" href="http://pragmaticworks.com/Resources/webinars/Default.aspx">http://pragmaticworks.com/Resources/webinars/Default.aspx</a></p>
<p>If Data Dude isn’t your thing don’t worry, there are lots of upcoming webinars. Next week Brian Knight is doing an intro to MDX session, and Ben Evans will be doing one on Data Driven Website Design. There’s also a nice selection of already recorded past webinars available for instant viewing. And like I said, it’s all free. How cool is that! </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/1998/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/1998/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/1998/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/1998/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/1998/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/1998/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/1998/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/1998/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/1998/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/1998/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/1998/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/1998/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/1998/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/1998/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1998&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2011/06/07/data-dude-webinar-for-pragmatic-works/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>
	</item>
		<item>
		<title>I&#8217;m a SQL People</title>
		<link>http://arcanecode.com/2011/03/10/im-a-sql-people/</link>
		<comments>http://arcanecode.com/2011/03/10/im-a-sql-people/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 00:05:40 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">https://arcanecode.wordpress.com/2011/03/10/im-a-sql-people/</guid>
		<description><![CDATA[My friend and fellow MVP Andy Leonard (blog &#124; twitter) has started an interesting project called SQL People. He’s interviewing people in the SQL Server community about their history, how they got into SQL Server, etc. My interview went online recently, you can read it at: http://sqlpeople.net/post.aspx?postHeaderId=31<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1977&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My friend and fellow MVP Andy Leonard (<a href="http://sqlblog.com/blogs/andy_leonard/default.aspx">blog</a> | <a href="http://twitter.com/#!/AndyLeonard">twitter</a>) has started an interesting project called <a href="http://sqlpeople.net/blogs.aspx">SQL People</a>. He’s interviewing people in the SQL Server community about their history, how they got into SQL Server, etc. My interview went online recently, you can read it at:</p>
<p><a title="http://sqlpeople.net/post.aspx?postHeaderId=31" href="http://sqlpeople.net/post.aspx?postHeaderId=31">http://sqlpeople.net/post.aspx?postHeaderId=31</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/1977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/1977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/1977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/1977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/1977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/1977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/1977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/1977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/1977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/1977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/1977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/1977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/1977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/1977/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1977&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2011/03/10/im-a-sql-people/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>
	</item>
		<item>
		<title>Deep Fried Arcane</title>
		<link>http://arcanecode.com/2011/01/11/deep-fried-arcane/</link>
		<comments>http://arcanecode.com/2011/01/11/deep-fried-arcane/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 07:01:00 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Podcasts]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server Integration Services]]></category>
		<category><![CDATA[SSIS]]></category>
		<category><![CDATA[Deep Fried Bytes]]></category>
		<category><![CDATA[Podcast]]></category>

		<guid isPermaLink="false">https://arcanecode.wordpress.com/2011/01/11/deep-fried-arcane/</guid>
		<description><![CDATA[At TechEd last year I was interviewed by the Deep Fried Bytes guys, along with another great SQL guy Denny Cherry. The topic of our interview was What Should Developers Know About SQL Server. (Click the link for the show.) In the interview we cover SQL Server Full Text Search, SQL Server Service Broker, and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1961&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>At TechEd last year I was interviewed by the Deep Fried Bytes guys, along with another great SQL guy <a href="http://itknowledgeexchange.techtarget.com/sql-server/">Denny Cherry</a>. The topic of our interview was <a href="http://deepfriedbytes.com/podcast/episode-61-what-should-developers-know-about-sql-server/">What Should Developers Know About SQL Server</a>. (Click the link for the show.)</p>
<p>In the interview we cover SQL Server Full Text Search, SQL Server Service Broker, and SQL Server Integration Services. And if you listen, you’ll hear about my favorite deep fried food!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/1961/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/1961/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/1961/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/1961/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/1961/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/1961/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/1961/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/1961/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/1961/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/1961/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/1961/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/1961/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/1961/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/1961/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1961&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2011/01/11/deep-fried-arcane/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>
	</item>
		<item>
		<title>SSRS Quick Tip &#8211; An item with the same key has already been added</title>
		<link>http://arcanecode.com/2010/07/30/ssrs-quick-tip-an-item-with-the-same-key-has-already-been-added/</link>
		<comments>http://arcanecode.com/2010/07/30/ssrs-quick-tip-an-item-with-the-same-key-has-already-been-added/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 07:01:15 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Reporting Services]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://arcanecode.com/?p=1938</guid>
		<description><![CDATA[I was in the process of creating a new report in SQL Server Reporting Services today. I was loading my dataset from a stored procedure, and when I hit the &#8220;Refresh Fields&#8221; button I recieved the following error: &#8220;Could not create a list of fields for the query. Verify that you can connect to the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1938&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was in the process of creating a new report in SQL Server Reporting Services today. I was loading my dataset from a stored procedure, and when I hit the &#8220;Refresh Fields&#8221; button I recieved the following error:</p>
<p>&#8220;Could not create a list of fields for the query. Verify that you can connect to the data source and that your query syntax is correct.&#8221;</p>
<p>When I clicked the details button I got this further information:</p>
<p>&#8220;An item with the same key has already been added.&#8221; Here&#8217;s a screen shot of my error. </p>
<p><a href="http://arcanecode.files.wordpress.com/2010/07/duplicate-col-name-error-in-ssrs.jpg"><img src="http://arcanecode.files.wordpress.com/2010/07/duplicate-col-name-error-in-ssrs.jpg?w=780" alt="" title="Duplicate Col Name error in SSRS"   class="aligncenter size-full wp-image-1939" /></a></p>
<p>Well this had me scratching my head, as I had made sure to run the stored procedure, and it executed with no errors. After doing some considerable research I finally found a question in the Technet forums that was tangentially related to the error. This gave me the clue to figure out what I had done. </p>
<p>In my stored procedure, I had inadvertantly included the same column name from two different tables. My query looked something like:</p>
<p>SELECT a.Field1, a.Field2, a.Field3, b.Field1, b.field99<br />
FROM TableA a JOIN TableB b on a.Field1 = b.Field1</p>
<p>SQL handled it just fine, since I had prefixed each with an alias (table) name. But SSRS uses only the column name as the key, not table + column, so it was choking. </p>
<p>The fix was easy, either rename the second column, i.e. b.Field1 AS Field01 or just omit the field all together, which is what I did. </p>
<p>As it took me a while to figure this out, tought I&#8217;d pass it along to anyone else who might be looking. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/1938/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/1938/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/1938/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/1938/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/1938/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/1938/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/1938/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/1938/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/1938/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/1938/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/1938/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/1938/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/1938/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/1938/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1938&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2010/07/30/ssrs-quick-tip-an-item-with-the-same-key-has-already-been-added/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>

		<media:content url="http://arcanecode.files.wordpress.com/2010/07/duplicate-col-name-error-in-ssrs.jpg" medium="image">
			<media:title type="html">Duplicate Col Name error in SSRS</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server Integration Services for Developers</title>
		<link>http://arcanecode.com/2010/07/23/sql-server-integration-services-for-developers/</link>
		<comments>http://arcanecode.com/2010/07/23/sql-server-integration-services-for-developers/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 00:25:28 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Integration Services]]></category>
		<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">https://arcanecode.wordpress.com/2010/07/23/sql-server-integration-services-for-developers/</guid>
		<description><![CDATA[Today I presented SSIS For Developers, we looked at how SSIS, commonly used in Data Warehousing, can also be used by most developers to solve issues that frequently come up in the course of their job. Data conversion and exporting data are two good examples, and we also looked at how to call your new [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1937&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I presented <a href="http://arcanecode.files.wordpress.com/2010/06/ssis-for-developers.pdf">SSIS For Developers</a>, we looked at how SSIS, commonly used in Data Warehousing, can also be used by most developers to solve issues that frequently come up in the course of their job. Data conversion and exporting data are two good examples, and we also looked at how to call your new SSIS job from your .Net application. </p>
<p>There are two code demos used during the presentation, both available at my Code Gallery site. The first is the basic <a href="http://code.msdn.microsoft.com/SSISForDevs">SSIS For Devs</a> demo with the three packages. The second is the more complex example showing how to call <a href="http://code.msdn.microsoft.com/ssisfromnet">SSIS from your .Net</a> application. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/1937/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/1937/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/1937/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/1937/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/1937/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/1937/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/1937/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/1937/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/1937/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/1937/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/1937/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/1937/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/1937/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/1937/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1937&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2010/07/23/sql-server-integration-services-for-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>
	</item>
		<item>
		<title>Linked Subreports in SQL Server 2008 Reporting Services</title>
		<link>http://arcanecode.com/2010/07/22/linked-subreports-in-sql-server-2008-reporting-services/</link>
		<comments>http://arcanecode.com/2010/07/22/linked-subreports-in-sql-server-2008-reporting-services/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 06:11:00 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Reporting Services]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">https://arcanecode.wordpress.com/2010/07/22/linked-subreports-in-sql-server-2008-reporting-services/</guid>
		<description><![CDATA[Note, before getting started with this lesson there are some prerequisites you should know about. Please read my post Getting Started with SQL Server 2008 to ensure you have everything setup correctly, otherwise you will be missing objects required to get the code here to work correctly. The previous lesson showed how to include a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1936&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Note, before getting started with this lesson there are some prerequisites you should know about. Please read my post <a href="http://arcanecode.com/2010/07/06/getting-started-with-sql-server-reporting-services-2008/">Getting Started with SQL Server 2008</a> to ensure you have everything setup correctly, otherwise you will be missing objects required to get the code here to work correctly.</p>
<p>The previous lesson showed how to include a subreport into another report. This could be used to link independent reports together into a single report. It can also be useful to have a related subreport. A subreport whose data is driven by that of the main report. This can be accomplished by the use of paramenters.</p>
<p>For this lab we’ll create a subreport that returns category totals for the region passed in from the main report. Note that this is a greatly simplified example to illustrate the technique. Even though in this sample everything comes from the same database, each report could just as easily come from completely different data sources. Subreports would be a great technique for combining data from different systems.</p>
<p><strong>Step 1. Create the subreport.</strong></p>
<blockquote><p>Use Contoso as the shared datasource. For the query, enter: </p>
</blockquote>
<blockquote><pre class="code"><span style="color:blue;">SELECT </span>[Region]
     <span style="color:gray;">, </span>[ProductCategoryName]
     <span style="color:gray;">, </span><span style="color:magenta;">SUM</span><span style="color:gray;">(</span>[TotalAmount]<span style="color:gray;">) </span><span style="color:blue;">AS </span>ProductTotal
  <span style="color:blue;">FROM </span>[ContosoRetailDW]<span style="color:gray;">.</span>[Report]<span style="color:gray;">.</span>[V_SubcategoryRegionTotalsByYear]
 <span style="color:blue;">WHERE </span>[Region] <span style="color:gray;">= </span>@pRegion
 <span style="color:blue;">GROUP BY </span>[Region]<span style="color:gray;">, </span>[ProductCategoryName]
 <span style="color:blue;">ORDER BY </span>[Region]<span style="color:gray;">, </span>[ProductCategoryName]</pre>
<p>  <a href="http://11011.net/software/vspaste"></a></p>
<p>Use a tabular report, move everything into the details area, Generic for the table style, and for the report name use “Subreport – Region Category Totals”.</p>
</blockquote>
<p><strong>Step 2. Cleanup the subreport.</strong></p>
<blockquote>
<p>Click the edge Region texbox in the header (so it’s selected instead of being edited), and press delete. Repeat with the [Region] textbox in the detail row. We won’t need it since Region will be displayed on the parent report.</p>
<p>Change the other headers to Category and Total. Make them wider, make what had been the Region column smaller but leave it, it will give a nice indent padding when included on the parent report. In the textbox properties for ProductTotal, make sure to set the Number to Currency, and in the Alignment area change the Horizontal to right align.</p>
<p>Remove the “Subreport – Region Category Totals” text box</p>
<p>Click on the main table grid, then move it to top of body. Collapse the body to fit the table.</p>
</blockquote>
<p><strong>Step 3. Add the parameter.</strong></p>
<blockquote>
<p>In the Report Data window, right click on Parameters and pick Add Parameter. Name the property Region. For the prompt, enter “Region – Hidden”. Since the prompt will never be visible, it really doesn’t matter, but making a habit of entering the name and the word Hidden will give a clear indicator that this parameter is a hidden one. </p>
<p>Leave the data type set to text, and check on “Allow blank value”. If you don’t, the report will error out when used as a subreport. Next, set the visibility to Hidden. This means it won’t appear if you run the report, but you can still pass in parameters, from another report or via a URL. Click OK to close the properties window. </p>
<p>Finally, we need to bind the parameter to the parameter the dataset needs. Right click on the dataset and go to properties. On the parameters area @pRegion should already be present (remember, it was part of the WHERE clause in the SQL query). Pick @Region in the drop down for Parameter Value. </p>
</blockquote>
<p><strong>Step 4. Create the main report.</strong></p>
<blockquote>
<p>Add a new report, using Contoso as the shared datasource. For the query, use:</p>
</blockquote>
<blockquote>
<pre class="code"><span style="color:blue;">SELECT </span>[RegionCountryName]
  <span style="color:blue;">FROM </span>[Report]<span style="color:gray;">.</span>[V_Regions]</pre>
<p>  <a href="http://11011.net/software/vspaste"></a></p>
<p>Use a tabular report, move the RegionCountryName to the details area, and pick Corporate for the style. Finally, for the name use “Regional Report”. </p>
</blockquote>
<p><strong>Step 5. Layout the report.</strong></p>
<blockquote>
<p>Since there’s only one column, expand it to take up the width of the body. </p>
<p>Right click on the row selector (the gray box with the lines on the left of the table) and pick Insert Row-&gt;Inside Group Below. </p>
<p>Into that area, drag a Subreport control from the toolbox. Note in this case there is only one column, but if there were multiple cells you could highlight them, right click and pick Merge Cells. </p>
</blockquote>
<p><strong>Step 6. Setup the subreport.</strong></p>
<blockquote>
<p>Right click on the subreport control. </p>
<p>Under “Use this report as a subreport” select the “Subreport – Region Category Totals”. Under the parameters area, click Add. Select Region under Name, and for the Value select RegionCountryName.</p>
</blockquote>
<p><strong>Step 7. Preview the report</strong></p>
<blockquote>
<p>Preview the report to see your results:</p>
</blockquote>
<p><a href="http://arcanecode.files.wordpress.com/2010/07/clip_image00241.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="clip_image002[4]" border="0" alt="clip_image002[4]" src="http://arcanecode.files.wordpress.com/2010/07/clip_image0024_thumb.gif?w=377&h=293" width="377" height="293" /></a></p>
<p><strong>Notes</strong></p>
<blockquote>
<p>Just a few notes. In this report, we left the table headers in the subreport (Category and Total). Often these are removed, to make the subreport blend in more with the parent. </p>
<p>Here only one parameter was passed, however you can pass multiple parameters if you need to. </p>
</blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/1936/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/1936/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/1936/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/1936/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/1936/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/1936/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/1936/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/1936/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/1936/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/1936/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/1936/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/1936/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/1936/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/1936/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1936&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2010/07/22/linked-subreports-in-sql-server-2008-reporting-services/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>

		<media:content url="http://arcanecode.files.wordpress.com/2010/07/clip_image0024_thumb.gif" medium="image">
			<media:title type="html">clip_image002[4]</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Subreports as Areas of Your SQL Server Reporting Services Report</title>
		<link>http://arcanecode.com/2010/07/20/using-subreports-as-areas-of-your-sql-server-reporting-services-report/</link>
		<comments>http://arcanecode.com/2010/07/20/using-subreports-as-areas-of-your-sql-server-reporting-services-report/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 06:11:00 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Reporting Services]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">https://arcanecode.wordpress.com/2010/07/20/using-subreports-as-areas-of-your-sql-server-reporting-services-report/</guid>
		<description><![CDATA[Note, before getting started with this lesson there are some prerequisites you should know about. Please read my post Getting Started with SQL Server 2008 to ensure you have everything setup correctly, otherwise you will be missing objects required to get the code here to work correctly. Subreports are an incredibly useful concept within Reporting [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1930&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Note, before getting started with this lesson there are some prerequisites you should know about. Please read my post <a href="http://arcanecode.com/2010/07/06/getting-started-with-sql-server-reporting-services-2008/">Getting Started with SQL Server 2008</a> to ensure you have everything setup correctly, otherwise you will be missing objects required to get the code here to work correctly.</p>
<p class="MsoNormal">Subreports are an incredibly useful concept within Reporting Services. They allow you to compartmentalize complex logic. They also allow you to create reports that can be used in many different parent reports. </p>
</p>
<p class="MsoNormal">In this lab, we’ll look at how to create a subreport and use it as a region within a parent report. For this example, we’ll create a base report, then a subreport that will function as an executive summary which we can place at the top of the report body. These types of summaries are commonplace in the reporting world. </p>
</p>
<p class="MsoNormal">Let’s get started by creating our base report. This will be identical to the base report used in other labs. </p>
</p>
<p class="Step"><strong>Step 1. Add the main report </strong>    </p>
</p>
<blockquote><p class="StepBody">As with our other reports, right click on the Reports branch in Solution Explorer, pick Add New Report, and (if you haven’t already disabled it) click next to move past the welcome screen. </p>
</p>
</blockquote>
<p class="Step"><strong>Step 2. Set the data source. </strong>    </p>
</p>
<blockquote><p class="StepBody">Pick the Contoso shared data source, or setup a new source to Contoso, and click Next. </p>
</p>
</blockquote>
<p class="Step"><strong>Step 3. Setup the query. </strong>    </p>
</p>
<blockquote><p class="StepBody">In the query builder, we’ll be using one of our views. Enter this SQL statement: </p>
</p>
</blockquote>
<p style="line-height:normal;margin:0 0 0 .5in;" class="MsoNormal"><span style="font-family:consolas;color:blue;">SELECT</span><span style="font-family:consolas;"> [FiscalYear] </span>    </p>
</p>
<p style="line-height:normal;margin:0 0 0 .5in;" class="MsoNormal"><span style="font-family:consolas;"><span>&#160;&#160;&#160;&#160;&#160; </span><span style="color:gray;">,</span>[ProductCategoryName] </span>    </p>
</p>
<p style="line-height:normal;margin:0 0 0 .5in;" class="MsoNormal"><span style="font-family:consolas;"><span>&#160;&#160;&#160;&#160;&#160; </span><span style="color:gray;">,</span>[ProductSubcategory] </span>    </p>
</p>
<p style="line-height:normal;margin:0 0 0 .5in;" class="MsoNormal"><span style="font-family:consolas;"><span>&#160;&#160;&#160;&#160;&#160; </span><span style="color:gray;">,</span>[Region] </span>    </p>
</p>
<p style="line-height:normal;margin:0 0 0 .5in;" class="MsoNormal"><span style="font-family:consolas;"><span>&#160;&#160;&#160;&#160;&#160; </span><span style="color:gray;">,</span>[TotalAmount] </span>    </p>
</p>
<p style="margin-left:.5in;" class="MsoNormal"><span style="font-family:consolas;"><span>&#160; </span><span style="color:blue;">FROM</span> [ContosoRetailDW]<span style="color:gray;">.</span>[Report]<span style="color:gray;">.</span>[V_SubcategoryRegionTotalsByYear]</span> </p>
</p>
<blockquote><p class="StepBody">and click next. </p>
</p>
</blockquote>
<p class="Step"><strong>Step 4. Set the format. </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">For the report type we’ll use the simple Tabular format, so just click Next. </p>
</blockquote>
</p>
<p class="Step"><strong>Step 5. Determine field placement in the report. </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">To keep this simple we’ll not use any groups on this report, so just put all report fields into the Details section. You can do it in one easy step by clicking on the top most item (FiscalYear), holding down the shift key, and clicking the bottom item (TotalAmount). This will select all of the fields, just click the Details button to move them. Then click Next. </p>
</p>
</blockquote>
<p class="Step"><strong>Step 6. Select the formatting Style </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">Once again we’ll go with Corporate for the style and click Next. </p>
</blockquote>
</p>
<p class="Step"><strong>Step 7. Name the report. </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">Finally we’ll give the report a name of “Regional Sales by Subcategory Subreports as Report Areas” and click Finish. </p>
</blockquote>
</p>
<p class="Step"><strong>Step 8. Format report columns </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">To make the report a little easier to read, expand the width of the columns and format the Total Amount as Currency. (See the previous labs if you don’t recall how to accomplish this.) </p>
</p>
</blockquote>
<p class="Step"><strong>Step 9. Add the subreport </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">It’s now time to create the subreport. Just like with a regular report, right click on the Reports branch in Solution Explorer, pick Add New Report, and (if you haven’t already disabled it) click next to move past the welcome screen. </p>
</p>
</blockquote>
<p class="Step"><strong>Step 10. Set the data source. </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">Pick the Contoso shared data source, or setup a new source to Contoso, and click Next. </p>
</blockquote>
</p>
<p class="Step"><strong>Step 11. Setup the query. </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">In the query builder, we’ll be using one of our views. Enter this SQL statement: </p>
</blockquote>
</p>
<blockquote><p style="line-height:normal;margin:0 0 0 .25in;" class="MsoNormal"><span style="font-family:consolas;color:blue;">SELECT</span><span style="font-family:consolas;"> [ProductCategoryName] </span>      </p>
</p>
<p style="line-height:normal;margin:0 0 0 .25in;" class="MsoNormal"><span style="font-family:consolas;"><span>&#160;&#160;&#160;&#160;&#160; </span><span style="color:gray;">,</span>[CategoryTotal] </span>      </p>
</p>
<p style="line-height:normal;margin:0 0 0 .25in;" class="MsoNormal"><span style="font-family:consolas;"><span>&#160; </span><span style="color:blue;">FROM</span> [ContosoRetailDW]<span style="color:gray;">.</span>[Report]<span style="color:gray;">.</span>[V_ProdcutCategoryExecutiveSummary] </span>      </p>
</p>
<p style="line-height:normal;margin:0 0 0 .25in;" class="MsoNormal"><span style="font-family:consolas;"><span>&#160;</span><span style="color:blue;">ORDER</span> <span style="color:blue;">BY</span> [ProductCategoryName] </span>      </p>
</p>
<p style="line-height:normal;margin-bottom:0;" class="MsoNormal"><span style="font-family:consolas;"></span></p>
<blockquote><p>&#160;</p>
<p> and click next. </p></blockquote>
</blockquote>
</p>
<p class="Step"><strong>Step 12. Set the format. </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">For the report type we’ll use the simple Tabular format, so just click Next. </p>
</blockquote>
</p>
<p class="Step"><strong>Step 13. Determine field placement in the report. </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">To keep this simple we’ll not use any groups on this report, so just put all report fields into the Details section. </p>
</blockquote>
</p>
<p class="Step"><strong>Step 14. Select the formatting Style </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">Unlike other reports, we will pick Generic for the style and click Next. </p>
</blockquote>
</p>
<p class="Step"><strong>Step 15. Name the report. </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">Finally we’ll give the report a name of “Subreport &#8211; Executive Summary” and click Finish. Note that is common to start the names of subreports with the name “Subreport” to make them easier to find. </p>
</p>
</blockquote>
<p class="Step"><strong>Step 16. Format subreport columns and body </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">To make the report a little easier to read, expand the width of the columns and format the Total Amount as Currency. (See the previous labs if you don’t recall how to accomplish this.) </p>
</p>
<p class="StepBody">In addition, we don’t need the body to be any wider that what is needed. Click on the text box that has the body title “Subreport – Executive Summary” and shrink it to match the width of the table. Then hover the mouse over the right side of the report and drag it over to bump against the right side of the table. </p>
</p>
<p class="Gotcha">Gotcha: If you try and shink the body first, it will not go. The right edge of the body can never be less than the right edge of the widest object (or the object whose right edge is farthest to the right). </p>
</p>
</blockquote>
<p class="Step"><strong>Step 17. Setup the detail header </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">Start by changing the titles of the detail grid to “Product Category” and “Total”. Now highlight the entire row by clicking the gray row selector square to the left of the row. </p>
</p>
<p class="StepBody">We can change the fore and background color of this row to match those of the main report. You can pick from standard colors, or enter your own color value. As an example of the first, go to the Color property, and from the drop down pick the color white. You will see the property name change to “White”.<span>&#160; </span>You could also have chose to just type in the word White. </p>
</p>
<p class="StepBody">You can also enter a hexadecimal value for the color. Click on the Background Color property and enter “#1c3a70”. (No quotes, but make sure to include the # so the entered value will be understood as hex and not a standard color, such as “White”. </p>
</p>
<p class="StepBody">Note that you can also change the values of each textbox independently, using the same technique. Most commonly though you will want to set the entire row. </p>
</p>
</blockquote>
<p class="Step"><strong>Step 18. The “Green Bar” effect </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">Once upon a time, in a computer room in the distant past, all reports were printed on paper that had alternating blocks of green and white background. This was known as “Green Bar” paper. The color made it easy to follow long lines of text across the page. </p>
</p>
<p class="StepBody">It’s possible to setup the same effect within our report today. Highlight the detail row, then in the Background Color of the properties window, click the drop down, then instead of a color pick the Expression option. For the expression, enter: </p>
</p>
<p class="StepBody"><span style="font-family:consolas;">=iif((RowNumber(<span style="color:blue;">NOTHING</span>) <span style="color:blue;">MOD</span> 2) = 0, <span style="color:#a31515;">&quot;LightBlue&quot;</span>, <span style="color:#a31515;">&quot;White&quot;</span>)</span> </p>
</p>
<p class="StepBody">Using the MOD function we determine if it’s an odd or even row, and set the background color accordingly. For the colors any color constant or hexadecimal value would work. </p>
</p>
</blockquote>
<p class="Step"><strong>Step 19. Add a value for the body header. </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">When a report is used as a subreport, any headers or footers are ignored. It can be useful to have a nice title though, so in this step we’ll create one. </p>
</p>
</blockquote>
<blockquote><p class="StepBody">19.1<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Hover over the bottom of the body, and drag it down to expand the body height. </p>
</p>
<p class="StepBody">19.2<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Now click on the grid. When the grid row/column bars appear, click on the one in the very upper left corner. When you do, the row/column bars hide themselves, and the grid sizing handles appear. In the upper left is an icon that points up/down/left/right. Click on it and drag the grid down, leaving space at the top for a textbox. Also leave a little space at the bottom that can serve as a gap between it and other items that might appear on the main report we place this subreport on. </p>
</p>
<p class="StepBody">19.3<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Next drag a textbox from the toolbox onto the top of the page. Expand the textbox to take up the width of the body. Increase the font size to 12, make the font bold, and center it. </p>
</p>
<p class="StepBody">19.4<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>We have a place now to put our title, lets grab some data to put there. Add a new dataset by right clicking on the Contoso data connection in the Report Data window. </p>
</p>
<p class="StepBody">19.5<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Name it “CurrentFiscalYear”, for the query text enter: </p>
</p>
<p style="line-height:normal;margin:0 0 0 .25in;" class="MsoNormal"><span style="font-family:consolas;color:blue;">SELECT</span><span style="font-family:consolas;"> <span style="color:fuchsia;">MAX</span><span style="color:gray;">(</span>FiscalYear<span style="color:gray;">)</span> <span style="color:blue;">AS</span> CurrentYear </span>      </p>
</p>
<p style="margin-left:.5in;" class="StepBody"><span style="font-family:consolas;"><span>&#160;&#160; </span><span style="color:blue;">FROM</span> [Report]<span style="color:gray;">.</span>[V_ProdcutCategoryExecutiveSummary]</span> </p>
</p>
<p class="StepBody">Click OK to save this new dataset. </p>
</p>
<p class="StepBody">19.6<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Returning to the textbox, right click and pick Expression. For the expression text, enter: </p>
</p>
<p class="StepBody"><span style="font-family:consolas;">=<span style="color:#a31515;">&quot;Executive Summary for &quot;</span> &amp; Sum(Fields!CurrentYear.Value, <span style="color:#a31515;">&quot;CurrentFiscalYear&quot;</span>)</span> </p>
</p>
<p class="StepBody">To build the center part of the string, click on the Datasets option under category. Then click on the CurrentFiscalYear dataset. In the Values area, one item appears, Sum(CurrentYear). Click on it to add the text to the current expression. </p>
</p>
<p class="StepBody">There is an oddity with getting fields from other datasets then the main one that supplies data to the body, they must be an aggregate expression such as Sum. However, since we are SUMing one value, the subreport will look like. </p>
</blockquote>
</p>
<p style="text-align:center;" class="StepBody" align="center"><span><a href="http://arcanecode.files.wordpress.com/2010/07/clip_image0022.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="clip_image002" border="0" alt="clip_image002" src="http://arcanecode.files.wordpress.com/2010/07/clip_image002_thumb2.jpg?w=278&h=70" width="278" height="70" /></a></span><span>&#160;&#160; </span><span><a href="http://arcanecode.files.wordpress.com/2010/07/clip_image0041.jpg"><img style="display:inline;border-width:0;" title="clip_image004" border="0" alt="clip_image004" src="http://arcanecode.files.wordpress.com/2010/07/clip_image004_thumb1.jpg?w=244&h=145" width="244" height="145" /></a></span> </p>
</p>
<blockquote><p class="StepBody"><i><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Design Mode<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Preview Mode </i></p>
</p>
</blockquote>
<p class="Step"><strong>Step 20. Add subreport to main report. </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<blockquote><p class="StepBody">Adding the subreport is quite simple. First, expand the body to make room above the grid similar to what was done in the above step. Then, drag the subreport from the Solution Explorer onto a blank area of the body. </p>
</p>
<p class="StepBody">Positioning it can be a bit of a pain, there’s no nice “put in the center” button. But with a little math you can accomplish it. </p>
</p>
<p class="StepBody">Return to the subreport a moment, and click on the grid which should take up the entire width of the body. In the properties window, expand the Size property to see the width. In this case it’s 2.3 inches. </p>
</p>
<p class="StepBody">Back in the main report, repeating the procedure with the main report’s grid, we see the width is 6.58 inches. Now it’s easy, (6.58 – 2.3) / 2 yields 2.14 inches. Use this for the left property of the subreport. The width isn’t that important, just set it wide in this case. </p>
</p>
</blockquote>
<p class="Step"><strong>Step 21. Preview the report. </strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<p class="Step"><strong></strong></p>
<p>&#160;</p>
</p>
<p style="text-align:center;" class="StepBody" align="center"><span><a href="http://arcanecode.files.wordpress.com/2010/07/clip_image0063.gif"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="clip_image006" border="0" alt="clip_image006" src="http://arcanecode.files.wordpress.com/2010/07/clip_image006_thumb3.gif?w=486&h=317" width="486" height="317" /></a></span> </p>
</p>
<blockquote><p class="StepBody">As you see, you now have an attractive subreport that you can reuse in multiple reports. </p>
</blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/1930/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/1930/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/1930/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/1930/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/1930/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/1930/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/1930/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/1930/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/1930/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/1930/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/1930/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/1930/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/1930/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/1930/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1930&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2010/07/20/using-subreports-as-areas-of-your-sql-server-reporting-services-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>

		<media:content url="http://arcanecode.files.wordpress.com/2010/07/clip_image002_thumb2.jpg" medium="image">
			<media:title type="html">clip_image002</media:title>
		</media:content>

		<media:content url="http://arcanecode.files.wordpress.com/2010/07/clip_image004_thumb1.jpg" medium="image">
			<media:title type="html">clip_image004</media:title>
		</media:content>

		<media:content url="http://arcanecode.files.wordpress.com/2010/07/clip_image006_thumb3.gif" medium="image">
			<media:title type="html">clip_image006</media:title>
		</media:content>
	</item>
		<item>
		<title>Report Headers and Footers</title>
		<link>http://arcanecode.com/2010/07/19/report-headers-and-footers/</link>
		<comments>http://arcanecode.com/2010/07/19/report-headers-and-footers/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 06:11:00 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server Reporting Services]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">https://arcanecode.wordpress.com/2010/07/19/report-headers-and-footers/</guid>
		<description><![CDATA[Note, before getting started with this lesson there are some prerequisites you should know about. Please read my post Getting Started with SQL Server 2008 to ensure you have everything setup correctly, otherwise you will be missing objects required to get the code here to work correctly. A common feature to most reports are headers [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1923&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Note, before getting started with this lesson there are some prerequisites you should know about. Please read my post <a href="http://arcanecode.com/2010/07/06/getting-started-with-sql-server-reporting-services-2008/">Getting Started with SQL Server 2008</a> to ensure you have everything setup correctly, otherwise you will be missing objects required to get the code here to work correctly.</p>
<p>A common feature to most reports are headers and footers that describe the report, and supply additional information such as the page numbering or print date. In this lab we’ll look at ways to customize the header and footer. </p>
<p>We’ll start by creating a basic report, then adding the headers and footers to it. </p>
<p><strong>Step 1. Add the report</strong></p>
<blockquote><p>As with our other reports, right click on the Reports branch in Solution Explorer, pick Add New Report, and (if you haven’t already disabled it) click next to move past the welcome screen. </p>
</blockquote>
<p><strong>Step 2. Set the data source.</strong></p>
<blockquote><p>Pick the Contoso shared data source, or setup a new source to Contoso, and click Next.</p>
</blockquote>
<p><strong>Step 3. Setup the query.</strong></p>
<blockquote><p>In the query builder, we’ll be using one of our views. Enter this SQL statement:</p>
</blockquote>
<blockquote><pre class="code"><span style="color:blue;">SELECT </span>[FiscalYear]
      <span style="color:gray;">,</span>[ProductCategoryName]
      <span style="color:gray;">,</span>[ProductSubcategory]
      <span style="color:gray;">,</span>[Region]
      <span style="color:gray;">,</span>[TotalAmount]
<span style="color:blue;">FROM </span>[ContosoRetailDW]<span style="color:gray;">.</span>[Report]<span style="color:gray;">.</span>[V_SubcategoryRegionTotalsByYear]</pre>
</blockquote>
<blockquote>
<p>and click next. </p>
</blockquote>
<p><strong>Step 4. Set the format.</strong></p>
<blockquote>
<p>For the report type we’ll use the simple Tabular format, so just click Next.</p>
</blockquote>
<p><strong>Step 5. Determine field placement in the report.</strong></p>
<blockquote>
<p>To keep this simple we’ll not use any groups on this report, so just put all report fields into the Details section. You can do it in one easy step by clicking on the top most item (FiscalYear), holding down the shift key, and clicking the bottom item (TotalAmount). This will select all of the fields, just click the Details button to move them. Then click Next. </p>
</blockquote>
<p><strong>Step 6. Select the formatting Style</strong></p>
<blockquote>
<p>Once again we’ll go with Corporate for the style and click Next.</p>
</blockquote>
<p><strong>Step 7. Name the report.</strong></p>
<blockquote>
<p>Finally we’ll give the report a name of “Regional Sales by Subcategory Headers and Footers” and click Finish.</p>
</blockquote>
<p><b></b></p>
<p><strong>Step 8. Format report columns</strong></p>
<blockquote>
<p>To make the report a little easier to read, expand the width of the columns and format the Total Amount as Currency. (See the previous labs if you don’t recall how to accomplish this.)</p>
<p>Previewing the report shows our data. There’s a lot of it, so let’s say we are the sales manager and we want to apply filters so we are only looking at pieces of our sales. </p>
</blockquote>
<p><strong>Step 9. Add a header area.</strong></p>
<blockquote>
<p>To add a header area to the report, simply right click anywhere outside the report body and select “Add Page Header”.</p>
</blockquote>
<p><strong>Step 10. Add a title.</strong></p>
<blockquote>
<p>A blank, white canvas should appear above your report body. Here you can create a header. Go to the toolbox, and drag in a Text Box. In it enter “Regional Sales Report”. Click on the text box and grab the sizing handles to enlarge it. Sometimes this can be a little tricky, if you click inside the text box it assumes you want to enter or edit the text and puts you in edit mode. You have to click right on the edge of the text box area to make the sizing handles appear. </p>
<p>Now add some visual impact. Either right click to access the fonts or use the toolbar above the design area. Make the font bold, and bump it up a few sizes, 16 generally works well. </p>
</blockquote>
<p><strong>Step 11. Add page numbers.</strong></p>
<blockquote>
<p>Drag another text box into the area. This time instead of static text we’ll use an expression to put in page numbers. Position the text box in the upper right corner of the report. </p>
<p>Right click on the text box, and in the pop up menu pick “Expression”. </p>
<p>In the expression builder you have a blank slate, only the beginning = is supplied for you. Similar to Excel, all expressions must start with an = sign. </p>
<p>The expression builder is very full featured and powerful, you can do a lot of complex things with it. It uses a VB.Net like language. In this lab though we’ll do something similar and concatenate some static text and build in variables to form a Page x of xx expression. </p>
<p>After the = sign enter “Page “ then an ampersand “&amp;”. Page is simply static text, and the &amp; will be used to join together our return value. </p>
<p>In the lower half of the Expression dialog you will see a Category and Item area, these are designed to make it easier to build expressions. Click on the “Built in Fields” Category. On the right the Item area will populate with the valid fields. Click on PageNumber. </p>
<p>Return to the upper area where it says “Set expression for Value” and after the page number type in &amp; “ of “ &amp; . Then go back to the Item list and click TotalPages. Your Expression dialog should now look like:</p>
</blockquote>
<p><a href="http://arcanecode.files.wordpress.com/2010/07/clip_image0025.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="clip_image002" border="0" alt="clip_image002" src="http://arcanecode.files.wordpress.com/2010/07/clip_image002_thumb5.gif?w=546&h=375" width="546" height="375" /></a></p>
<blockquote>
<p>Click OK to close the Expression builder. </p>
</blockquote>
<p><strong>Step 12. Format the page number.</strong></p>
<blockquote>
<p>Select the text box for the page number by clicking on the edge, then using the toolbar right align the page number box. Page numbers are typically quite small on the header, so let’s bump down the font to 8 point. </p>
</blockquote>
<p><strong>Step 13. Resize the header.</strong></p>
<blockquote>
<p>In this example our header isn’t very large, but when we added it SSRS gave us a considerable amount of space. Let’s resize this to something more appropriate. </p>
<p>Hover over the dotted line between the header and report body with your mouse. It should turn into the up/down sizing handle. When it does, click and drag it up. </p>
<p>As an alternative, you could click in the empty area of the header, then in the Properties pane of VS/BIDS enter an explicit Height value. This is useful for situations where you have specific requirements that the header must be of an exact size. This often occurs with things like pre-printed forms or paper with the letterhead already printed on it. </p>
</blockquote>
<p><strong>Step 14. Preview the header.</strong></p>
<blockquote>
<p>OK, all done with this part. Switch to the Preview tab to see the header in action. </p>
</blockquote>
<p><a href="http://arcanecode.files.wordpress.com/2010/07/clip_image004.jpg"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="clip_image004" border="0" alt="clip_image004" src="http://arcanecode.files.wordpress.com/2010/07/clip_image004_thumb.jpg?w=486&h=112" width="486" height="112" /></a></p>
<p><strong>Step 15. Add the footer.</strong></p>
<blockquote>
<p>Working with footers are identical to working with headers. Start by right clicking in an empty spot in the design area and pick “Add Page Footer”.</p>
</blockquote>
<p><strong>Step 16. Add content.</strong></p>
<blockquote>
<p>Drag a text box onto the footer. Expand it to take up the entire width of the report, then enter the Expression dialog as you did before, right click and pick Expression from the menu. </p>
<p>It’s common for a business to want to copyright their intellectual property, so enter this as your expression:</p>
</blockquote>
<blockquote>
<pre class="code"><span style="color:gray;">=</span>&quot;Copyright &quot; <span style="color:gray;">&amp; </span><span style="color:magenta;">Year</span><span style="color:gray;">(</span><span style="color:blue;">Now</span><span style="color:gray;">()) &amp; </span>&quot; ArcaneCode.&quot;</pre>
</blockquote>
<p><a href="http://11011.net/software/vspaste"></a></p>
<blockquote>
<p>Hint: If you select Common Functions, Date &amp; Time in the Category area of the Expression builder, you’ll see many common functions. When you click on one helpful hints will appear to the right. </p>
<p>Since we have a lot of unused space, we’ll again shrink the footer like we did the header. This time though hover over the bottom of the footer to make the resizing mouse icon appear, then drag it up to shrink it. </p>
</blockquote>
<p><strong>Step 17. Test in the Preview pane.</strong></p>
<blockquote>
<p>Once again, return to the Preview tab, scroll down and the footer should look something like:</p>
</blockquote>
<p><a href="http://arcanecode.files.wordpress.com/2010/07/clip_image0062.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="clip_image006" border="0" alt="clip_image006" src="http://arcanecode.files.wordpress.com/2010/07/clip_image006_thumb2.gif?w=492&h=80" width="492" height="80" /></a></p>
<p><strong>Other ideas.</strong></p>
<blockquote>
<p>The things you can do in the header and footers are nearly infinite. Images, such as your corporate logo can be used. Trademarks, warning notices of intellectual property, print dates, the report name and URL, and the list of parameters used to generate the report are all common things that may appear in the header.</p>
</blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/1923/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/1923/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/1923/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/1923/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/1923/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/1923/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/1923/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/1923/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/1923/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/1923/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/1923/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/1923/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/1923/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/1923/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1923&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2010/07/19/report-headers-and-footers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>

		<media:content url="http://arcanecode.files.wordpress.com/2010/07/clip_image002_thumb5.gif" medium="image">
			<media:title type="html">clip_image002</media:title>
		</media:content>

		<media:content url="http://arcanecode.files.wordpress.com/2010/07/clip_image004_thumb.jpg" medium="image">
			<media:title type="html">clip_image004</media:title>
		</media:content>

		<media:content url="http://arcanecode.files.wordpress.com/2010/07/clip_image006_thumb2.gif" medium="image">
			<media:title type="html">clip_image006</media:title>
		</media:content>
	</item>
		<item>
		<title>What I learned at TechEd</title>
		<link>http://arcanecode.com/2010/06/15/what-i-learned-at-teched/</link>
		<comments>http://arcanecode.com/2010/06/15/what-i-learned-at-teched/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 21:23:24 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[DW/BI]]></category>
		<category><![CDATA[PowerPivot]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[Confio]]></category>
		<category><![CDATA[OData]]></category>
		<category><![CDATA[Red Gate]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[TechEd]]></category>

		<guid isPermaLink="false">https://arcanecode.wordpress.com/2010/06/15/what-i-learned-at-teched/</guid>
		<description><![CDATA[Last week I was at the Microsoft TechEd conference in North America, along with over 10,000 of my closest friends. I spent a lot of time in the Microsoft floor area talking to people, and came away with some interesting info about new technologies. As I’m sharing some of these at the Steel City SQL [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1855&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Last week I was at the Microsoft TechEd conference in North America, along with over 10,000 of my closest friends. I spent a lot of time in the Microsoft floor area talking to people, and came away with some interesting info about new technologies. As I’m sharing some of these at the Steel City SQL user group tonight, I thought I’d share here too. </p>
<p>First up is OData, the Open Data Protocol from Microsoft. It is an ATOM feed but for data. People can publish under the OData format and be able to consume the data from either a JSON or AtomPub. You can also add security, should you wish to have data available to many consumers but only on a permission basis. You can learn more at <a href="http://www.odata.org">http://www.odata.org</a> </p>
<p>Next up is Microsoft’s new “<a href="http://www.microsoft.com/windowsazure/dallas/" target="_blank">Dallas</a>” project. Dallas is the code name for a data marketplace on it’s Azure platform. Through Dallas users and vendors will be able to consume / provide data feeds. Some will be free, others will be at some cost. There is a <a href="https://www.sqlazureservices.com/Catalog.aspx" target="_blank">catalog</a> through which consumers can look at the various feeds available. This is very much in it’s infancy but there are a few feeds which you can look at and preview. </p>
<p>Microsoft’s <a href="http://www.microsoft.com/sqlserver/2008/en/us/parallel-data-warehouse.aspx" target="_blank">SQL Server 2008 R2 Parallel Data Warehouse</a> looked interesting, although it fits a very niche market. It’s an appliance you can purchase that is essentially a rack of SQL Servers. One is the master server, and coordinates all the child servers. As a DBA you manage what appears to be a “normal” instance of a SQL Server. Behind the scenes the controller will propagate changes to the other servers in it’s hub. Scaling can be achieved by simply adding more servers to the existing rack, or additional racks as needed. PDW becomes economical starting around 10 terabytes and scales to well over 100 terabytes of data. </p>
<p>The folks at Red Gate have a new tool called <a href="http://www.red-gate.com/products/SQL_Search/index.htm" target="_blank">SQL Search</a> that they have released for free to the community. SQL Search is an add-on for SQL Server Management Studio that does lightening fast searches of object names in your database. Just pick the database name and term to search for and SQL Search will populate a grid with all possible matches. If you double click on the row it will navigate SSMS’s Object Explorer pane to the correct spot in the navigation tree with your object. Further, if the object is a view, stored proc, etc it will even display the SQL of the object and highlight the searched item. And did I mention it’s free?</p>
<p>Speaking of cool, free tools the folks at <a href="http://www.confio.com/" target="_blank">Confio</a> have created a free version of their popular Ignite tool called <a href="http://www.ignitefree.com/" target="_blank">IgniteFree</a>. It is a real time performance monitoring tool that will work with not just SQL Server but Oracle and DB2 as well. They have versions of the tool that run on both Windows and Unix/Linux. </p>
<p>PowerPivot continues to fascinate and excite me, while I was at TechEd I won a copy of “<a href="http://www.amazon.com/Professional-Microsoft-PowerPivot-Excel-SharePoint/dp/0470587377/ref=sr_1_2?ie=UTF8&amp;s=books&amp;qid=1276568947&amp;sr=8-2" target="_blank">PowerPivot for Excel and SharePoint</a>”. I had this on my “to buy” list anyway so considered myself lucky. I’m about a sixth of the way through the book and it has been really good so far. It starts with a quick tour of the Excel piece, then walks you through the SharePoint install so you can quickly get up and running in a test environment. Later chapters delve much more deeply into PowerPivot. If you are looking for a good PowerPivot book I would recommend it. </p>
<p>Finally, even if you couldn’t be there you can watch the sessions from this and past Tech Ed’s. Microsoft has released them to the general public at <a title="http://www.msteched.com/" href="http://www.msteched.com/">http://www.msteched.com/</a></p>
<p>&#160;</p>
<p><em><font size="1">*FTC Discloser, I am in the “Friends of Red Gate” program where I get copies of their tools in order to test and provide feedback. In this case the disclaimer probably isn’t necessary since the SQL Search tool is freely available to all, but I’d prefer to keep things above board. </font></em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/1855/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/1855/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/1855/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/1855/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/1855/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/1855/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/1855/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/1855/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/1855/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/1855/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/1855/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/1855/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/1855/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/1855/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1855&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2010/06/15/what-i-learned-at-teched/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Saturday 41 &#8211; Atlanta</title>
		<link>http://arcanecode.com/2010/04/24/sql-saturday-41-atlanta/</link>
		<comments>http://arcanecode.com/2010/04/24/sql-saturday-41-atlanta/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 07:08:00 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[SQL Saturday]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[TechEd]]></category>

		<guid isPermaLink="false">https://arcanecode.wordpress.com/2010/04/24/sql-saturday-41-atlanta/</guid>
		<description><![CDATA[Today is April 24, 2010 and I’m in Atlanta speaking at SQL Saturday number 41. I’m giving three sessions today. I guess I’m just a glutton for punishment, LOL. My first session is an Introduction to Business Intelligence / Data Warehousing. In it I am covering the basics, it’s a true introductory talk where we’ll [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1826&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today is April 24, 2010 and I’m in Atlanta speaking at SQL Saturday number 41. I’m giving three sessions today. I guess I’m just a glutton for punishment, LOL.</p>
<p>My first session is an Introduction to Business Intelligence / Data Warehousing. In it I am covering the basics, it’s a true introductory talk where we’ll demystify all the buzz words surrounding Business Intelligence. You can download the <a href="http://arcanecode.files.wordpress.com/2010/04/introtodatawarehousing_2010_04.pdf" target="_blank">slides from here</a>.</p>
<p>My next session is Off and Running with PowerPivot for Excel 2010. Learn the ins and outs of this exciting new tool from Microsoft, see how you can enable your users to do their own Business Intelligence. The slides are ready <a href="http://arcanecode.files.wordpress.com/2010/04/powerpivot.pdf" target="_blank">from this location</a>.</p>
<p>OK, an update before this blog entry even posts, Vidas Matelis just published his step by step guide for getting SharePoint 2010, SQL Server 2008 R2, and PowerPivot all up and going on a single box. (And when I say just, I mean it went up just as I was typing up this post.) Vidas knows a lot about PowerPivot, it’s a great blog to add to your short list. I have a link to his blog in my slide deck, but wanted to pass along a specific link to his install guide, you can find it at <a title="http://powerpivot-info.com/post/66-step-by-step-guide-on-installing-powerpivot-for-sharepoint" href="http://powerpivot-info.com/post/66-step-by-step-guide-on-installing-powerpivot-for-sharepoint">http://powerpivot-info.com/post/66-step-by-step-guide-on-installing-powerpivot-for-sharepoint</a> .</p>
<p>The final session I’ll be doing is on Full Text Searching. You can download the code samples and slides from my Code Gallery site, <a href="http://code.msdn.microsoft.com/SqlServerFTS">http://code.msdn.microsoft.com/SqlServerFTS</a>.</p>
<p>Speaking of Full Text Search, I’ll be doing an Interactive Session at Tech-Ed in New Orleans on Full Text Searching. The session is now in the catalog: <a href="http://northamerica.msteched.com/topic/list?keyword=DAT07-INT">http://northamerica.msteched.com/topic/list?keyword=DAT07-INT</a> If you are coming to New Orleans for Tech Ed I’d love to see you there. I’ll also be in the Microsoft Data booth during part of the event, so come on by and say Hi!</p>
<p>I hope to be able to sneak in a few sessions today as well, there will be 49 different sessions at SQL Saturday #41 to pick from (7 tracks, and 7 sessions per track) so it promises to have something for everyone. If you want to follow the fun on Twitter, our official hash tag is <a href="http://twitter.com/#search?q=%23sqlsat41" target="_blank">#sqlsat41</a> .</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/1826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/1826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/1826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/1826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/1826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/1826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/1826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/1826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/1826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/1826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/1826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/1826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/1826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/1826/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1826&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2010/04/24/sql-saturday-41-atlanta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>
	</item>
		<item>
		<title>Live Streaming from SQL Saturday 41</title>
		<link>http://arcanecode.com/2010/04/23/live-streaming-from-sql-saturday-41/</link>
		<comments>http://arcanecode.com/2010/04/23/live-streaming-from-sql-saturday-41/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 13:31:13 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[Data Warehousing]]></category>
		<category><![CDATA[DW/BI]]></category>
		<category><![CDATA[Education]]></category>
		<category><![CDATA[SQL Saturday]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://arcanecode.wordpress.com/2010/04/23/live-streaming-from-sql-saturday-41/</guid>
		<description><![CDATA[One of the sponsors for tomorrow&#8217;s SQL Saturday in Atlanta Georgia, a company named Set Focus, is going to be live streaming three presentations from the event. I just got the word that my session, &#34;Introduction to Data Warehousing/Business Intelligence&#34; was selected as one of the sessions. My session kicks off the event at 8:30 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1824&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the sponsors for tomorrow&#8217;s SQL Saturday in Atlanta Georgia, a company named Set Focus, is going to be live streaming three presentations from the event. I just got the word that my session, &quot;Introduction to Data Warehousing/Business Intelligence&quot; was selected as one of the sessions. My session kicks off the event at 8:30 a.m. Eastern time. Information and a link to the stream site can be found on Set Focus’s blog:</p>
<p><a title="http://blogs.setfocus.com/radar/2010/04/22/streaming-sqlsaturday/" href="http://blogs.setfocus for making this happen.com/radar/2010/04/22/streaming-sqlsaturday/">http://blogs.setfocus.com/radar/2010/04/22/streaming-sqlsaturday/</a></p>
<p>SQL Saturday 41 was sold out some time ago, and there is even quite a waiting list, so if you&#8217;re unable to attend then at least you can sit in on three of the sessions via the live stream. The other two sessions to be streamed are &quot;SQL Server Memory Deep Dive&quot; by Kevin Boles and &quot;Database Design Patterns&quot; by Louis Davidson. Both are fellow Microsoft MVPs and excellent presenters, I know you&#8217;ll enjoy their presentations as well.</p>
<p>Live streaming technology really excites me. While I feel that you can get the best experience and education from being live at the event, I also understand that this is not always possible for everyone. Work conflicts, distance, family obligations, or the event simply being sold out, as this one is, can limit a person&#8217;s ability to attend in person. Live streaming events such as SQL Saturday really helps us to extend our reach into the community and to help serve those who for whatever reason cannot be with us at the event. I want to give a great big thanks to the folks over at <a href="http://www.setfocus.com/" target="_blank">Set Focus</a> for making this happen.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/1824/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/1824/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/1824/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/1824/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/1824/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/1824/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/1824/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/1824/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/1824/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/1824/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/1824/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/1824/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/1824/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/1824/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1824&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2010/04/23/live-streaming-from-sql-saturday-41/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>
	</item>
		<item>
		<title>Introducing Microsoft PowerPivot</title>
		<link>http://arcanecode.com/2009/11/20/introducing-microsoft-powerpivot/</link>
		<comments>http://arcanecode.com/2009/11/20/introducing-microsoft-powerpivot/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 18:27:44 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[Data Warehousing]]></category>
		<category><![CDATA[DW/BI]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PASS]]></category>
		<category><![CDATA[PowerPivot]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server Analysis Services]]></category>
		<category><![CDATA[SQL Server Reporting Services]]></category>
		<category><![CDATA[SSAS]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[Excel]]></category>

		<guid isPermaLink="false">http://arcanecode.wordpress.com/2009/11/20/introducing-microsoft-powerpivot/</guid>
		<description><![CDATA[What is PowerPivot? Well according to Microsoft: “PowerPivot is Microsoft Self-Service Business Intelligence” I can see from the glazed looks you are giving your monitor that was clear as mud. So let’s step back a bit and first define what exactly is Business Intelligence. Business Intelligence Business Intelligence, often referred to as simply “BI”, is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1702&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>What is PowerPivot? Well according to Microsoft:</p>
<p><i><font size="4">“PowerPivot is Microsoft Self-Service Business Intelligence”</font></i></p>
<p>I can see from the glazed looks you are giving your monitor that was clear as mud. So let’s step back a bit and first define what exactly is <i>Business Intelligence</i>.</p>
<p><b>Business Intelligence</b></p>
<p>Business Intelligence, often referred to as simply “BI”, is all about taking data you already have and making sense of it. Being able to take that information and turn it from a raw jumble of individual facts and transform it into knowledge that you can take informed actions on. </p>
<p>In every organization there is already someone who is doing BI, although they may not realize it. Microsoft (and many IT departments) refer to this person as “<i>that guy</i>”. A power user, who grabs data from anyplace he (or she) can get it, then uses tools like Excel or Access to slice it, dice it, and analyze it. This person might be an actual Business Analyst, but more often it’s someone for who BI is not their main job. Some common examples of people doing their own BI today are production managers, accountants, engineers, or sales managers, all who need information to better do their job. Let’s look at an illustration that will make it a bit clearer.</p>
<p>In this example, put yourself in the role of a sales manager. You have gotten IT to extract all of your sales orders for the last several years into an Excel spreadsheet. In order to determine how well your sales people are doing, you need to measure their performance. You’ve decided that the amount sold will be a good measure, and use Excel to give you totals. </p>
<p><a href="http://arcanecode.files.wordpress.com/2009/11/introex01.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="IntroEx01" border="0" alt="IntroEx01" src="http://arcanecode.files.wordpress.com/2009/11/introex01_thumb.jpg?w=284&h=104" width="284" height="104" /></a> </p>
<p>In BI terms, the column “Total Sales” is known as a <i>measure</i>, or sometimes a <i>fact</i>, as it measures something, in this case the sales amount. The grand total sales amount is often called an <i>aggregation</i>, as it totals up the individual rows of data that IT gave us. But now you might be wondering why Andy’s sales are so low? Well, now you want to dig deeper and look at sales by year. </p>
<p><a href="http://arcanecode.files.wordpress.com/2009/11/introex02.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="IntroEx02" border="0" alt="IntroEx02" src="http://arcanecode.files.wordpress.com/2009/11/introex02_thumb.jpg?w=419&h=106" width="419" height="106" /></a> </p>
<p>In BI terms, the names of the sales people are a <i>dimension</i>. Dimensions are often either a “who” (who sold stuff) or a “what” (what stuff did we sell). Places (where was it sold) and dates (when was it sold) are also common dimensions. In this case the sales dates across the top (2007, 2008, 2009) are a date dimension. When we use two or more dimensions to look at our measures, we have a <i>pivot table</i>. </p>
<p>Now we can see a picture emerging. It’s obvious that Andy must have been hired as a new salesperson in late 2008, since he shows no sales for 2007 and very small amount in 2008. But for Paul and Kimberly we can look at something called <i>trends</i> in the BI world. Kimberly shows a nice even trend, rising slowly over the last three years and earns a gold star as our top performer. </p>
<p>By being able to drill down into our data, we spot another trend that was not readily obvious when just looking at the grand totals. Paul has been trending downward so fast the speed of light looks slow. Clearly then we now have information to take action on, commonly known as <i>actionable intelligence</i>.</p>
<p><b>So remind me, why do we need PowerPivot?</b></p>
<p>As you can see in the above example, “that guy” in your company clearly has a need to look at this data in order to do his job. Not only does he need to review it, he also has the issue of how to share this information with his co-workers. Unfortunately in the past the tools available to “that guy” have had some drawbacks. The two main tools used by our analyst have been either Excel, or a complete BI solution involving a data warehouse and SQL Server Analysis Services.</p>
<p>Excel’s main limitations center around the volume of data needed to do good analysis. Excel has limits to the number of rows it can store, and for large datasets a spreadsheet can consume equally large amounts of disk space. This makes the spreadsheet difficult to share with coworkers. In addition mathematical functions like aggregations could be slow. On the good side, Excel is readily available to most workers, and a solution can be put together fairly quickly. </p>
<p>A full blown BI solution has some major benefits over the Excel solution. A data warehouse is created, and then SQL Server Analysis Services (often abbreviated as SSAS) is used to precalculate aggregations for every possible way an analyst might wish to look at them. The data is then very easy to share via tools like Excel and SQL Server Reporting Services. While very robust and powerful solution, it does have some drawbacks. It can take quite a bit of time to design, code, and implement both the data warehouse and the analysis services pieces of the solution. In addition it can also be expensive for IT to implement such a system.</p>
<p><b>Faster than a speeding bullet, more powerful than a locomotive, it’s PowerPivot!</b></p>
<p>PowerPivot combines the best of both worlds. In fact, it’s not one tool but two: PowerPivot for Microsoft Excel 2010, and PowerPivot for SharePoint 2010. What’s the difference you ask? Good question. </p>
<p><b>PowerPivot for Microsoft Excel 2010</b></p>
<p>PowerPivot acts as an Add-on for Excel 2010, and in many ways is quite revolutionary. First, it brings the full power of SQL Server Analysis Services right into Excel. All of the speed and power of SSAS is available right on your desktop. Second, it uses a compression technology that allows vast amounts of data to be saved in a minimal amount of space. Millions of rows of data can now be stored, sorted, and aggregated in a reasonable amount of disk space with great speed. </p>
<p>PowerPivot can draw its data from a wide variety of sources. As you might expect, it can pull from almost any database. Additionally it can draw data from news feeds, SQL Server Reporting Services, other Excel sheets, it can even be typed in manually if need be. </p>
<p>Another issue that often faces the business analyst is the freshness of the data. The information is only as good as the date it was last imported into Excel. Traditionally “that guy” only got extracts of the database as IT had time, since it was often a time consuming process. PowerPivot addresses this through its <i>linked tables</i> feature. PowerPivot will remember where your data came from, and with one simple button click can refresh the spreadsheet with the latest information.</p>
<p>Because PowerPivot sits inside Microsoft Excel, it not only can create basic pivot tables but has all the full featured functionality of Excel at its disposal. It can format pivot tables in a wide array of styles, create pivot charts and graphs, and combine these together into useful dashboards. Additionally PowerPivot has a rich set of mathematical functionally, combining the existing functions already in Excel with an additional set of functions called Data Analysis eXpressions or DAX. </p>
<p><b>PowerPivot for SharePoint 2010</b></p>
<p>PowerPivot for Excel 2010 clearly solves several issues around the issue of analysis. It allows users to quickly create spreadsheets, pivot tables, charts, and more in a compact amount of space. If you recall though, creation was only half of “that guys” problem. The other half was sharing his analysis with the rest of his organization. That’s where PowerPivot for SharePoint 2010 comes into play.</p>
<p>Placing a PowerPivot Excel workbook in SharePoint 2010 not only enables traditional file sharing, but also activates several additional features. First, the spreadsheet is hosted right in the web browser. Thus users who might not have made the transition to Excel 2010 can still use the PowerPivot created workbook, slicing and filtering the data to get the information they require. </p>
<p>Data can also be refreshed on an automated, scheduled basis. This ensures the data is always up to date when doing analysis. Dashboards can also be created from the contents of a worksheet and displayed in SharePoint. Finally these PowerPivot created worksheets can be used as data sources for such tools as SQL Server Reporting Services. </p>
<p><b>Limitations</b></p>
<p>First, let me preface this by saying as of this writing all of the components are either in CTP (Community Technology Preview, a pre-beta) or Beta state. Thus there could be some changes between now and their final release next year. </p>
<p>To use the PowerPivot for Excel 2010 components, all you have to have is Excel 2010 and the PowerPivot add-in. If you want to share the workbook and get all the rich functionality SharePoint has to offer, you’ll have to have SharePoint 2010, running Excel Services and PowerPivot 2010 Services. You’ll also have to have SQL Server 2008 R2 Analysis Services running on the SharePoint 2010 box. Since you’ll have to have a SQL Server instance installed to support SharePoint this is not a huge limitation, especially since SSAS comes with SQL Server at no extra cost. </p>
<p>One thing I wish to make clear, SharePoint 2010 itself can run using any version of SQL Server from SQL Server 2005 on. It is the PowerPivot service that requires 2008 R2 Analysis Services. </p>
<p>One other important item to note: at some point the load upon the SharePoint 2010 server may grow too large if especially complex analysis is being done. Fortunately SharePoint 2010 ships with several tools that allow administrators to monitor the load and plan accordingly. At the point where the load is too big, it is a clear indication it’s time to transition from a PowerPivot solution to a full BI solution using a data warehouse and SQL Server Analysis Services. </p>
<p><b>What does PowerPivot mean for business users?</b></p>
<p>For business users, and especially “that guy”, it means complex analysis tools can be created in a short amount of time. Rich functionality makes it easier to spot trends and produce meaningful charts and graphs. It also means this information can be shared with others in the organization easily, without imposing large burdens on the corporate e-mail system or local file sharing mechanisms. </p>
<p>No longer will users be dependent on IT for their analysis, they will have the power to create everything they need on their own, truly bringing “self service BI” to fruition.</p>
<p><b>What does PowerPivot mean for Business Intelligence IT Pros?</b></p>
<p>The first reaction many BI developers have when hearing about PowerPivot is “oh no, this is going to put me out of a job!” Far from it, I firmly believe PowerPivot will create even more work for BI Professionals like myself. </p>
<p>As upper management grows to rely on the information provided by PowerPivot, they will also begin to understand the true value BI can bring to an organization. Selling a new BI solution into an organization where none currently exists can be difficult, as it can be hard to visualize how such a solution would work and the value it brings. PowerPivot allows BI functionality to be brought into an organization at a low development cost, proving the value of BI with minimal investment. Thus when there is a need to implement a larger, traditional BI project those same managers will be more forthcoming with the dollars.</p>
<p>Second, as users pull more and more data, they are going to want that data better organized than they will find in their current transactional business systems. This will in turn spur the need to create many new data warehouses. Likewise the IT department will also want data warehouses created, to reduce the load placed on those same transactional business systems. </p>
<p>I also foresee PowerPivot being used by BI Pros themselves to create solutions. The database structure of many transactional database systems can be difficult to understand even for experienced IT people, much less users. BI Pros can use PowerPivot to add a layer of abstraction between the database and the users, allowing business analysts to do their job without having to learn the complexity of a database system.</p>
<p>BI Pros can also use PowerPivot to implement quick turnaround solutions for customers, bringing more value for the customer’s dollar. When a BI Pro can prove him (or her) self by providing rich functionality in a short time frame it’s almost always the case they are brought back in for multiple engagements. </p>
<p>PowerPivot also provides great value to BI Pros who are employed full time in an enterprise organization. They can create solutions much quicker than before, freeing them up to do other valuable tasks. In addition PowerPivot solutions can provide a “stop gap” solution, pushing the date at which the organization needs to spend the dollars for a full blown BI solution and allowing IT to plan better. </p>
<p>Finally I see great value in PowerPivot as a prototyping tool for larger BI projects. Now users can see their data, interact with it, analyze it, and ensure the required measures and dimensions are present before proceeding with the larger project. </p>
<p>I’ll reiterate, if anything I believe PowerPivot will create an explosion of work for the Business Intelligence Professional.</p>
<p><b>Where can I learn more?</b></p>
<p>Well right here for one. I have become quite interested in PowerPivot since seeing it at the SQL PASS 2009 Summit. I think it will be a valuable tool for both myself and my customers. This will be the first of many blog posts to come on PowerPivot. I am also beginning a series of presentations on PowerPivot for local user groups and code camp events. The first will be Saturday, November 21<sup>st</sup> 2009 at the <a href="http://www.sharepointsaturday.org/birmingham/default.aspx">SharePoint Saturday in Birmingham Alabama</a>, but there will be many more to come. (If you’d like me to come speak at your group just shoot me an <a href="mailto:arcanecode@gmail.com?subject=PowerPivot%20Presentation">e-mail</a> and we’ll see what we can arrange.)</p>
<p>There’s also the PowerPivot site itself:</p>
<ul>
<li><a href="http://powerpivot.com/">http://powerpivot.com/</a></li>
</ul>
<p>I’ve also found a small handful of blogs on PowerPivot, listed in no particular order:</p>
<ul>
<li><a href="http://powerpivotpro.com/">http://powerpivotpro.com/</a></li>
<li><a href="http://powerpivotgeek.com/">http://powerpivotgeek.com/</a></li>
<li><a href="http://powerpivottwins.com/">http://powerpivottwins.com/</a></li>
<li><a href="http://powerpivot-info.com/">http://powerpivot-info.com/</a></li>
</ul>
<p><b>Summary</b></p>
<p>Thanks for sticking with me, I know this was a rather long blog post but PowerPivot has a lot of rich functionality to offer. While PowerPivot is still in the CTP/Beta stage as of this writing, I see more and more interest in the community, which will continue to grow as PowerPivot moves closer to release. I hope this post has set you off on the right step and you’ll continue to come back for more information. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/1702/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/1702/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/1702/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/1702/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/1702/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/1702/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/1702/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/1702/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/1702/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/1702/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/1702/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/1702/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/1702/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/1702/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1702&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2009/11/20/introducing-microsoft-powerpivot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>

		<media:content url="http://arcanecode.files.wordpress.com/2009/11/introex01_thumb.jpg" medium="image">
			<media:title type="html">IntroEx01</media:title>
		</media:content>

		<media:content url="http://arcanecode.files.wordpress.com/2009/11/introex02_thumb.jpg" medium="image">
			<media:title type="html">IntroEx02</media:title>
		</media:content>
	</item>
		<item>
		<title>Full Text Searching a FILESTREAM VARBINARY (MAX) Column</title>
		<link>http://arcanecode.com/2009/05/28/full-text-searching-a-filestream-varbinary-max-column/</link>
		<comments>http://arcanecode.com/2009/05/28/full-text-searching-a-filestream-varbinary-max-column/#comments</comments>
		<pubDate>Thu, 28 May 2009 06:04:00 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[FILESTREAM]]></category>
		<category><![CDATA[FTS]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server Full Text Searching]]></category>
		<category><![CDATA[Full Text Search]]></category>

		<guid isPermaLink="false">http://arcanecode.wordpress.com/2009/05/28/full-text-searching-a-filestream-varbinary-max-column/</guid>
		<description><![CDATA[In the past I’ve written that Full Text Searching has the ability to index documents stored in a VARBINARY(MAX) field. However, I have never really gone into any details on how to do this. Today I will remedy that by demonstrating how to Full Text Seach not only using a VARBINARY(MAX) field, but one that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1589&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In the past I’ve written that Full Text Searching has the ability to index documents stored in a VARBINARY(MAX) field. However, I have never really gone into any details on how to do this. Today I will remedy that by demonstrating how to Full Text Seach not only using a VARBINARY(MAX) field, but one that has been stored using FILESTREAM. Even though these examples will be done against the data we’ve stored with FILESTREAM over the lessons from <a href="http://arcanecode.com/2009/05/18/enabling-filestream-on-sql-server-2008/">the last few days</a>, know that this technique is identical for binary objects stored in a VARBINARY(MAX) field without using FILESTREAM. </p>
<p>Let’s start by creating a catalog to hold our Full Text data. </p>
<pre></pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#39;font-size:11px;margin:0;"><a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=CREATE&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">CREATE</a> FULLTEXT <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=CATALOG&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">CATALOG</a> FileStreamFTSCatalog <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=AS&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">AS</a> <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=DEFAULT&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">DEFAULT</a>;</pre>
<p>Pretty normal, now we need to create a full text index on the “DocumentRepository” table we created in <a href="http://arcanecode.com/2009/05/20/creating-tables-and-inserting-rows-with-filestream/">this series</a>. When you look at the syntax though, you may notice a minor difference from the CREATE FULLTEXT INDEX examples I’ve shown in the past:</p>
<pre></pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#39;font-size:11px;margin:0;"><a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=CREATE&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">CREATE</a> FULLTEXT <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=INDEX&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">INDEX</a> <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=ON&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">ON</a> dbo.DocumentRepository
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#39;font-size:11px;margin:0;">(DocumentName, Document TYPE <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=COLUMN&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">COLUMN</a> DocumentExtension)
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#39;font-size:11px;margin:0;"><a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=KEY&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">KEY</a> <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=INDEX&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">INDEX</a> PK__Document__3214EC277F60ED59
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#39;font-size:11px;margin:0;"><a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=ON&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">ON</a> FileStreamFTSCatalog
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#39;font-size:11px;margin:0;"><a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=WITH&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">WITH</a> CHANGE_TRACKING AUTO;
</pre>
<p>Here you can see I am indexing two fields. The first is the “DocumentName”, which is passed in as the first parameter and looks like other examples. We won’t actually be using it in this example, however I included it to demonstrate you can index multiple columns even when one of them is a VARBINARY(MAX) column. </p>
<p>The second parameter indexes the VARBINARY(MAX) “Document” column itself, but notice the TYPE COLUMN after the column name. In order to Full Text Index a VARBINARY(MAX) column you must also have a column with the file extension in it. You then pass in the name of column after the TYPE COLUMN. In this example, the document extension is stored in the “DocumentExtension” column. Since the document extension can be stored in a column with any name, we let the Full Text engine know which column by passing it in after the TYPE COLUMN keyword. The remainder of the command is like other examples <a href="http://arcanecode.com/2007/06/27/getting-started-with-sql-server-2005-full-text-searching-part-2-%E2%80%93-the-indexes/">I’ve shown in the past</a>. </p>
<p>Now we can run a normal SELECT…CONTAINS query against the “Document” field. </p>
<pre></pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#39;font-size:11px;margin:0;"><a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=SELECT&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">SELECT</a> ID, DocumentName 
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#39;font-size:11px;margin:0;"><a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=FROM&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">FROM</a> dbo.DocumentRepository
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#39;font-size:11px;margin:0;"><a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=WHERE&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">WHERE</a> <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=CONTAINS&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">CONTAINS</a>(Document, '<span style="color:#8b0000;">Shrew</span>');
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#39;font-size:11px;margin:0;"></pre>
<p>I’ll leave it to you to run, for me it returned one row, with “TheTamingOfTheShrew.doc”. If you want to try it again, use “Elinor”, and you should get back “KingJohn.doc”. </p>
<p>As you can see, performing a Full Text Search against a VARBINARY(MAX) column is quite easy, all you have to do is indicate the document type by using the TYPE COLUMN. There are two more things you should know. First, the column containing the document extension must be of type CHAR, NCHAR, VARCHAR, or NVARCHAR. Second, the document type must be recognized by SQL Server. To get a list of all valid document types, simply query the fulltext_document_types catalog view like so: </p>
<pre></pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,&#39;font-size:11px;margin:0;"><a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=SELECT&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">SELECT</a> * <a href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=FROM&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">FROM</a> sys.fulltext_document_types;</pre>
<p>This will give you a list of all file extensions understood by SQL Server. Each row actually represents a filter. Each filter represents a DLL that implements the IFilter interface. It is possible to add additional filters to the system. For example, Microsoft offers the “Microsoft Filter Pack”. You may have noticed that out of the box SQL Server 2008 supports the older Office 2003 documents, but not the more recent Office 2007 formats. To add these newer formats to your SQL Server, Microsoft provides the afore mentioned filter pack. While installing it is beyond the scope of this aritcle you can find complete instructions for downloand and installation at <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;945934">http://support.microsoft.com/default.aspx?scid=kb;en-us;945934</a> . </p>
<p>The Full Text Search features provided by SQL Server continue to amaze me with how powerful they are, yet how easy they are to implment. With the information here you can easily search through documents stored in a VARBINARY(MAX) field, even when those documents are actually stored via the new SQL Server 2008 FILESTREAM. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/1589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/1589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/1589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/1589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/1589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/1589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/1589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/1589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/1589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/1589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/1589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/1589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/1589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/1589/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1589&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2009/05/28/full-text-searching-a-filestream-varbinary-max-column/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>
	</item>
		<item>
		<title>Accessing FILESTREAM Data From A Client .NET Application &#8211; Part 2 Downloading a File</title>
		<link>http://arcanecode.com/2009/05/27/accessing-filestream-data-from-a-client-net-application-part-2-downloading-a-file/</link>
		<comments>http://arcanecode.com/2009/05/27/accessing-filestream-data-from-a-client-net-application-part-2-downloading-a-file/#comments</comments>
		<pubDate>Wed, 27 May 2009 06:03:00 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[.Net 3.5]]></category>
		<category><![CDATA[C Sharp]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[FILESTREAM]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008]]></category>

		<guid isPermaLink="false">http://arcanecode.wordpress.com/2009/05/27/accessing-filestream-data-from-a-client-net-application-part-2-downloading-a-file/</guid>
		<description><![CDATA[In the previous entry we covered how to upload a file to SQL Server using the FILESTREAM, new to SQL Server 2008. In this post we will look at retrieving a file from SQL Server using FILESTREAM. If you missed yesterday’s installment, a simple front end was created, the full project can be found at [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1584&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In the previous entry we covered how to upload a file to SQL Server using the FILESTREAM, new to SQL Server 2008. In this post we will look at retrieving a file from SQL Server using FILESTREAM. If you missed yesterday’s installment, a simple front end was created, the full project can be found at the Code Gallery site <a href="http://code.msdn.microsoft.com/FileStreamFTS">http://code.msdn.microsoft.com/FileStreamFTS</a> . </p>
<p>The interface is very simple:</p>
<p><a href="http://arcanecode.files.wordpress.com/2009/05/image4.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://arcanecode.files.wordpress.com/2009/05/image_thumb4.png?w=495&h=347" width="495" height="347" /></a> </p>
<p>The grid is a Data View Grid that shows the ID and Document information from the table we previously created. (If you want to see the code to populate the grid see the project.) The user picks a row, then clicks on the Get File button. </p>
<div style="font-family:consolas;background:white;color:black;font-size:10pt;">
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">private</span> <span style="color:blue;">void</span> btnGetFile_Click(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)</p>
<p style="margin:0;">&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Reset in case it was used previously</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; lblStatus.Text = <span style="color:#a31515;">&quot;&quot;</span>;</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">if</span> (dgvFiles.CurrentRow != <span style="color:blue;">null</span>)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Grab the ID (Primary Key) for the current row</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">int</span> ID = (<span style="color:blue;">int</span>)dgvFiles.CurrentRow.Cells[0].Value;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Now Save the file to the folder passed in the second</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// paramter. </span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">FileTransfer</span>.GetFile2(ID, <span style="color:#a31515;">@&quot;D:\Docs\Output\&quot;</span>);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// And let user know it&#8217;s OK </span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; lblStatus.Text = <span style="color:#a31515;">&quot;File Retrieved&quot;</span>;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160; }</p>
</p></div>
<p>The code is very simple, the heart of it is the FileTransfer.GetFile static method. Two values are passed in, the integer ID, which is the primary key from the database, and the path to save the file to. Here I simply hard coded a path, in a real life application you will want to give the user the ability to enter a path. Let’s take a look at the GetFile routine.</p>
<div style="font-family:consolas;background:white;color:black;font-size:10pt;">
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color:blue;">void</span> GetFile(<span style="color:blue;">int</span> ID, <span style="color:blue;">string</span> outputPath)</p>
<p style="margin:0;">&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Setup database connection</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">SqlConnection</span> sqlConnection = <span style="color:blue;">new</span> <span style="color:#2b91af;">SqlConnection</span>(</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#a31515;">&quot;Integrated Security=true;server=(local)&quot;</span>);</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">SqlCommand</span> sqlCommand = <span style="color:blue;">new</span> <span style="color:#2b91af;">SqlCommand</span>();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; sqlCommand.Connection = sqlConnection;</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">try</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; sqlConnection.Open();</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Everything we do with FILESTREAM must always be in </span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// the context of a transaction, so we&#8217;ll start with </span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// creating one.</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">SqlTransaction</span> transaction </p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; = sqlConnection.BeginTransaction(<span style="color:#a31515;">&quot;mainTranaction&quot;</span>);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; sqlCommand.Transaction = transaction;</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// The SQL gives us 3 values. First the PathName() method of </span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// the Document field is called, we&#8217;ll need it to use the API</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Second we call a special function that will tell us what</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// the context is for the current transaction, in this case </span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// the &quot;mainTransaction&quot; we started above. Finally it gives</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// the name of the document, which the app will use when it</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// creates the document but is not strictly required as </span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// part of the FILESTREAM.</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; sqlCommand.CommandText</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; = <span style="color:#a31515;">&quot;SELECT Document.PathName()&quot;</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + <span style="color:#a31515;">&quot;, GET_FILESTREAM_TRANSACTION_CONTEXT() &quot;</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + <span style="color:#a31515;">&quot;, DocumentName &quot;</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + <span style="color:#a31515;">&quot;FROM FileStreamFTS.dbo.DocumentRepository &quot;</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + <span style="color:#a31515;">&quot;WHERE ID=@theID &quot;</span>;</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; sqlCommand.Parameters.Add(</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#a31515;">&quot;@theID&quot;</span>, <span style="color:#2b91af;">SqlDbType</span>.Int).Value = ID;</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">SqlDataReader</span> reader = sqlCommand.ExecuteReader();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">if</span> (reader.Read() == <span style="color:blue;">false</span>)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">throw</span> <span style="color:blue;">new</span> <span style="color:#2b91af;">Exception</span>(<span style="color:#a31515;">&quot;Unable to get BLOB data&quot;</span>);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// OK we have some data, pull it out of the reader into locals</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">string</span> path = (<span style="color:blue;">string</span>)reader[0];</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">byte</span>[] context = (<span style="color:blue;">byte</span>[])reader[1];</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">string</span> outputFilename = (<span style="color:blue;">string</span>)reader[2];</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">int</span> length = context.Length;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; reader.Close();</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Now we need to use the API we declared at the top of this class</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// in order to get a handle. </span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">SafeFileHandle</span> handle = OpenSqlFilestream(</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; path</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; , DESIRED_ACCESS_READ</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; , SQL_FILESTREAM_OPEN_NO_FLAGS</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; , context</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; , (<span style="color:#2b91af;">UInt32</span>)length, 0);</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Using the handle we just got, we can open up a stream from </span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// the database.</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">FileStream</span> databaseStream = <span style="color:blue;">new</span> <span style="color:#2b91af;">FileStream</span>(</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; handle, <span style="color:#2b91af;">FileAccess</span>.Read);</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// This file stream will be used to copy the data to disk</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">FileStream</span> outputStream </p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; = <span style="color:#2b91af;">File</span>.Create(outputPath + outputFilename); </p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Setup a buffer to hold the streamed data</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">int</span> blockSize = 1024 * 512;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">byte</span>[] buffer = <span style="color:blue;">new</span> <span style="color:blue;">byte</span>[blockSize];</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// There are two ways we could get the data. The simplest way</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// is to read the data, then immediately feed it to the output</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// stream using it&#8217;s Write feature (shown below, commented out.</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// The second way is to load the data into an array of bytes</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// (here implemented using the generic LIST). This would let</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// you manipulate the data in memory, then write it out (as</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// shown here), reupload it to another data stream, or do</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// something else entirely. </span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// If you want to go the simple way, just remove all the</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// fileBytes lines and uncomment the outputStream line.</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">List</span>&lt;<span style="color:blue;">byte</span>&gt; fileBytes = <span style="color:blue;">new</span> <span style="color:#2b91af;">List</span>&lt;<span style="color:blue;">byte</span>&gt;();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">int</span> bytesRead = databaseStream.Read(buffer, 0, buffer.Length);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">while</span> (bytesRead &gt; 0)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; bytesRead = databaseStream.Read(buffer, 0, buffer.Length);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">//outputStream.Write(buffer, 0, buffer.Length);</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">foreach</span> (<span style="color:blue;">byte</span> b <span style="color:blue;">in</span> buffer)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; fileBytes.Add(b);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Write out what is in the LIST to disk</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">foreach</span> (<span style="color:blue;">byte</span> b <span style="color:blue;">in</span> fileBytes)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">byte</span>[] barr = <span style="color:blue;">new</span> <span style="color:blue;">byte</span>[1];</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; barr[0] = b;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; outputStream.Write(barr, 0, 1);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Close the stream from the databaseStream</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; databaseStream.Close();</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Write out the file</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; outputStream.Close();</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Finally we should commit the transaction. </span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; sqlCommand.Transaction.Commit();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">catch</span> (System.<span style="color:#2b91af;">Exception</span> ex)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">MessageBox</span>.Show(ex.ToString());</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">finally</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; sqlConnection.Close();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">return</span>;</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160; }</p>
</p></div>
<p>The routine kicks off by opening a connection, then establishing a transaction. Remember from the previous lesson that every time you work with a FILESTREAM it has to be in a transaction. Next we basically duplicate the SQL used in the previous lesson, returning the path name, transaction context, and document name. The only difference is we pass in the ID as a parameter. With that, just like with the previous example we call the OpenSqlFilestream API. Note a difference, in this example the second parameter is “DESIRED_ACCESS_READ” as opposed to the write access we indicated previosly. </p>
<p>Once we have the “handle” we can create a FileStream for reading from the database. In this example I loop through the file stream, loading the data into a LIST of bytes. Once in memory we are free to work with it as we need to. In this example I simply loop back through the generic List and write the data to the file stream we opened on the disk for writing. If all you are doing is writing, it would be somewhat more efficient to write the code like so:</p>
<div style="font-family:consolas;background:white;color:black;font-size:10pt;">
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">int</span> bytesRead = databaseStream.Read(buffer, 0, buffer.Length);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">while</span> (bytesRead &gt; 0)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; bytesRead = databaseStream.Read(buffer, 0, buffer.Length);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; outputStream.Write(buffer, 0, buffer.Length);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Close the stream from the databaseStream</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; databaseStream.Close();</p>
</p></div>
<p>I simply eliminate the local byte array and write the buffer directly to the disk. Either way, the remainder is simple, just closing all the streams, commiting the transaction and closing the database connection. </p>
<p>This concludes the series on how to use FILESTREAM, in future posts we look into how to do Full Text Search with FILESTREAM stored objects. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/1584/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/1584/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/1584/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/1584/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/1584/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/1584/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/1584/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/1584/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/1584/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/1584/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/1584/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/1584/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/1584/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/1584/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1584&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2009/05/27/accessing-filestream-data-from-a-client-net-application-part-2-downloading-a-file/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>

		<media:content url="http://arcanecode.files.wordpress.com/2009/05/image_thumb4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Accessing FILESTREAM Data From A Client .NET Application &#8211; Part 1 Uploading a File</title>
		<link>http://arcanecode.com/2009/05/26/accessing-filestream-data-from-a-client-net-application-part-1-uploading-a-file/</link>
		<comments>http://arcanecode.com/2009/05/26/accessing-filestream-data-from-a-client-net-application-part-1-uploading-a-file/#comments</comments>
		<pubDate>Tue, 26 May 2009 06:02:00 +0000</pubDate>
		<dc:creator>arcanecode</dc:creator>
				<category><![CDATA[.Net 3.5]]></category>
		<category><![CDATA[C Sharp]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[FILESTREAM]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008]]></category>

		<guid isPermaLink="false">http://arcanecode.wordpress.com/2009/05/26/accessing-filestream-data-from-a-client-net-application-part-1-uploading-a-file/</guid>
		<description><![CDATA[The best way to work with documents in a database is via a .Net application. I created a simple Windows forms project to access the table I created in previous lessons. I named the application FileLoader, you can the entire project at the Code Gallery site http://code.msdn.microsoft.com/FileStreamFTS . The interface is very simple: As you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1581&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The best way to work with documents in a database is via a .Net application. I created a simple Windows forms project to access the table I created in previous lessons. I named the application FileLoader, you can the entire project at the Code Gallery site <a href="http://code.msdn.microsoft.com/FileStreamFTS">http://code.msdn.microsoft.com/FileStreamFTS</a> . </p>
<p>The interface is very simple:</p>
<p><a href="http://arcanecode.files.wordpress.com/2009/05/image3.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://arcanecode.files.wordpress.com/2009/05/image_thumb3.png?w=495&h=347" width="495" height="347" /></a> </p>
<p>As you can see there are two main functions, the upper half uploads a file to the SQL Server. The lower half displays the files already in the table, lets the user pick one and then click the GetFile button to save it locally. Today we’ll look at the Upload File functionality. Here is the code:</p>
<div style="font-family:consolas;background:white;color:black;font-size:10pt;">
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">private</span> <span style="color:blue;">void</span> btnUploadFile_Click(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)</p>
<p style="margin:0;">&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Reset in case it was used previously</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; lblStatus.Text = <span style="color:#a31515;">&quot;&quot;</span>;</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Make sure user entered something</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">if</span> (txtFile.Text.Length == 0)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">MessageBox</span>.Show(<span style="color:#a31515;">&quot;Must supply a file name&quot;</span>);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; lblStatus.Text = <span style="color:#a31515;">&quot;Must supply file name&quot;</span>;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">return</span>;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Make sure what user entered is valid</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">FileInfo</span> fi = <span style="color:blue;">new</span> <span style="color:#2b91af;">FileInfo</span>(txtFile.Text);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">if</span> (!fi.Exists)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">MessageBox</span>.Show(<span style="color:#a31515;">&quot;The file you entered does not exist.&quot;</span>);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; lblStatus.Text = <span style="color:#a31515;">&quot;The file you entered does not exist.&quot;</span>;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">return</span>;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Upload the file to the database</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">FileTransfer</span>.UploadFile(txtFile.Text);</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Refresh the datagrid to show the newly added file</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; LoadDataGridView();</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Let user know it was uploaded</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; lblStatus.Text = fi.Name + <span style="color:#a31515;">&quot; Uploaded&quot;</span>;</p>
<p style="margin:0;">&#160;&#160;&#160; }</p>
</p></div>
<p>The real line of importance is the FileTransfer.UploadFile. This calls a static method in a class I named FileTransfer.cs. In order to use FILESTREAM there is an API call we have to make, so at the header area of the FileTransfer we have a lot of declarations. These are pretty much a straight copy from the MSDN help files.</p>
<div style="font-family:consolas;background:white;color:black;font-size:10pt;">
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//These contants are passed to the OpenSqlFilestream()</span></p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//API DesiredAccess parameter. They define the type</span></p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//of BLOB access that is needed by the application.</span></p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">const</span> <span style="color:#2b91af;">UInt32</span> DESIRED_ACCESS_READ = 0&#215;00000000;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">const</span> <span style="color:#2b91af;">UInt32</span> DESIRED_ACCESS_WRITE = 0&#215;00000001;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">const</span> <span style="color:#2b91af;">UInt32</span> DESIRED_ACCESS_READWRITE = 0&#215;00000002;</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//These contants are passed to the OpenSqlFilestream()</span></p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//API OpenOptions parameter. They allow you to specify</span></p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//how the application will access the FILESTREAM BLOB</span></p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//data. If you do not want this ability, you can pass in</span></p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//the value 0. In this code sample, the value 0 has</span></p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//been defined as SQL_FILESTREAM_OPEN_NO_FLAGS.</span></p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">const</span> <span style="color:#2b91af;">UInt32</span> SQL_FILESTREAM_OPEN_NO_FLAGS = 0&#215;00000000;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">const</span> <span style="color:#2b91af;">UInt32</span> SQL_FILESTREAM_OPEN_FLAG_ASYNC = 0&#215;00000001;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">const</span> <span style="color:#2b91af;">UInt32</span> SQL_FILESTREAM_OPEN_FLAG_NO_BUFFERING = 0&#215;00000002;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">const</span> <span style="color:#2b91af;">UInt32</span> SQL_FILESTREAM_OPEN_FLAG_NO_WRITE_THROUGH = 0&#215;00000004;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">const</span> <span style="color:#2b91af;">UInt32</span> SQL_FILESTREAM_OPEN_FLAG_SEQUENTIAL_SCAN = 0&#215;00000008;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">const</span> <span style="color:#2b91af;">UInt32</span> SQL_FILESTREAM_OPEN_FLAG_RANDOM_ACCESS = 0&#215;00000010;</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//This structure defines the format of the final parameter to the</span></p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//OpenSqlFilestream() API.</span></p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//This statement imports the OpenSqlFilestream API so that it</span></p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//can be called in the Main() method below.</span></p>
<p style="margin:0;">&#160;&#160;&#160; [<span style="color:#2b91af;">DllImport</span>(<span style="color:#a31515;">&quot;sqlncli10.dll&quot;</span>, SetLastError = <span style="color:blue;">true</span>, CharSet = <span style="color:#2b91af;">CharSet</span>.Unicode)]</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">static</span> <span style="color:blue;">extern</span> <span style="color:#2b91af;">SafeFileHandle</span> OpenSqlFilestream(</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">string</span> Filestreamath,</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">uint</span> DesiredAccess,</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">uint</span> OpenOptions,</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">byte</span>[] FilestreamTransactionContext,</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">uint</span> FilestreamTransactionContextLength,</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">Int64</span> AllocationSize);</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//This statement imports the Win32 API GetLastError().</span></p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//This is necessary to check whether OpenSqlFilestream</span></p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:green;">//succeeded in returning a valid / handle</span></p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160; [<span style="color:#2b91af;">DllImport</span>(<span style="color:#a31515;">&quot;kernel32.dll&quot;</span>, SetLastError = <span style="color:blue;">true</span>)]</p>
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">static</span> <span style="color:blue;">extern</span> <span style="color:#2b91af;">UInt32</span> GetLastError();</p>
</p></div>
<p>OK, with that out of the way, I’ve created a public, static method to upload the file. Here is the full routine:</p>
<div style="font-family:consolas;background:white;color:black;font-size:10pt;">
<p style="margin:0;">&#160;&#160;&#160; <span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color:blue;">void</span> UploadFile(<span style="color:blue;">string</span> fileName)</p>
<p style="margin:0;">&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Establish db connection</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">SqlConnection</span> sqlConnection = <span style="color:blue;">new</span> <span style="color:#2b91af;">SqlConnection</span>(</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#a31515;">&quot;Integrated Security=true;server=(local)&quot;</span>);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">SqlTransaction</span> transaction = <span style="color:blue;">null</span>;</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Create a File Info object so you can easily get the</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// name and extenstion. As an alternative you could</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// choose to pass them in,&#160; or use some other way</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// to extract the extension and name. </span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">FileInfo</span> fi = <span style="color:blue;">new</span> <span style="color:#2b91af;">FileInfo</span>(fileName);</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">try</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Open the file as a stream</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">FileStream</span> sourceFile = <span style="color:blue;">new</span> <span style="color:#2b91af;">FileStream</span>(fileName</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; , <span style="color:#2b91af;">FileMode</span>.OpenOrCreate, <span style="color:#2b91af;">FileAccess</span>.Read);</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Create the row in the database</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; sqlConnection.Open();</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">SqlCommand</span> cmd = <span style="color:blue;">new</span> <span style="color:#2b91af;">SqlCommand</span>();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; cmd.Connection = sqlConnection;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; cmd.CommandText = <span style="color:#a31515;">&quot;INSERT INTO &quot;</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + <span style="color:#a31515;">&quot;FileStreamFTS.dbo.DocumentRepository&quot;</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + <span style="color:#a31515;">&quot;(DocumentExtension, DocumentName) VALUES (&#8216;&quot;</span> </p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + fi.Extension + <span style="color:#a31515;">&quot;&#8217;, &#8216;&quot;</span> </p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + fi.Name + <span style="color:#a31515;">&quot;&#8217;)&quot;</span>;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; cmd.ExecuteNonQuery();</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Now upload the file. It must be done inside a transaction.</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; transaction = sqlConnection.BeginTransaction(<span style="color:#a31515;">&quot;mainTranaction&quot;</span>);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; cmd.Transaction = transaction;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; cmd.CommandText = <span style="color:#a31515;">&quot;SELECT Document.PathName(), &quot;</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + <span style="color:#a31515;">&quot;GET_FILESTREAM_TRANSACTION_CONTEXT() &quot;</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + <span style="color:#a31515;">&quot;FROM FileStreamFTS.dbo.DocumentRepository &quot;</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + <span style="color:#a31515;">&quot;WHERE ID=(select max(id) from FileStreamFTS.dbo.DocumentRepository)&quot;</span>;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">SqlDataReader</span> rdr = cmd.ExecuteReader();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">if</span> (rdr.Read() == <span style="color:blue;">false</span>)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">throw</span> <span style="color:blue;">new</span> <span style="color:#2b91af;">Exception</span>(<span style="color:#a31515;">&quot;Could not get file stream context&quot;</span>);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Get the path</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">string</span> path = (<span style="color:blue;">string</span>)rdr[0];</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Get a file stream context</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">byte</span>[] context = (<span style="color:blue;">byte</span>[])rdr[1];</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">int</span> length = context.Length;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; rdr.Close();</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Now use the API to get a reference (handle) to the filestream</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">SafeFileHandle</span> handle = OpenSqlFilestream(path</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; , DESIRED_ACCESS_WRITE</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; , SQL_FILESTREAM_OPEN_NO_FLAGS</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; , context, (<span style="color:#2b91af;">UInt32</span>)length, 0);</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Now create a true .Net filestream to the database</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// using the handle we got in the step above</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2b91af;">FileStream</span> dbStream = <span style="color:blue;">new</span> <span style="color:#2b91af;">FileStream</span>(handle, <span style="color:#2b91af;">FileAccess</span>.Write);</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Setup a buffer to hold the data we read from disk</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">int</span> blocksize = 1024 * 512;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">byte</span>[] buffer = <span style="color:blue;">new</span> <span style="color:blue;">byte</span>[blocksize];</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Read from file and write to DB</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">int</span> bytesRead = sourceFile.Read(buffer, 0, buffer.Length);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">while</span> (bytesRead &gt; 0)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; dbStream.Write(buffer, 0, buffer.Length);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; bytesRead = sourceFile.Read(buffer, 0, buffer.Length);</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:green;">// Done reading, close all of our streams and commit the file</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; dbStream.Close();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; sourceFile.Close();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; transaction.Commit();</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">catch</span> (<span style="color:#2b91af;">Exception</span> e)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">if</span> (transaction != <span style="color:blue;">null</span>)</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; transaction.Rollback();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">throw</span> e;</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; <span style="color:blue;">finally</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; sqlConnection.Close();</p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;">&#160;&#160;&#160; }</p>
</p></div>
<p>First we open a connection to the SQL Server, then create a FileInfo object to make it simple to extract the file name and extension. Next a record is inserted into the database that will act as a place holder. It has the name of the file and the extension, but no file yet. I did go ahead and open a FileStream to the source file, located on the disk. We’ll need this later to upload the file. </p>
<p>Next you will see that I begin a transaction. Every time you work with a FILESTREAM it must always be in the context of a transaction. After that a SQL Data Reader is created that has three pieces of information. First, it calls the PathName() function for the Document field in our table. The PathName() will be needed later when we call the API. The second field is returned from the GET_FILESTREAM_TRANSACTION_CONTEXT function, and returns the transaction context for the transaction. Note this is not the name (in this example “mainTransaction”), but the context which is a special value. These two values are then copied into local variables which will be used in calling the OpenSqlFilestream API. In this example I also retrieve the DocumentName field, this is used by the code when it writes the file to the database, but is not strictly needed for the FILESTREAM. </p>
<p>Next you will see the call to the OpenSqlFilestream API, which returns a “handle”. This handle is then used to create a FileStream object. Using this newly created FileStream (here named dbStream) we can then upload the file. Now the main work begins. After setting up a buffer, we then simply read from the source file stream into the buffer, then write the exact same buffer to the database FileStream. The loop continues until there are no more bytes in the source. </p>
<p>At this point we are essentially done. We close the streams, commit the transaction, and in the finally block close the SQL database connection. The file should now be in the database. I do want to point out one thing. In the SQL to get the information to the row just uploaded, I use a subquery to get the max(id), essentially returning the last row just inserted. This is fine for this simple example, when the database has just one user. In your production systems where you are likely to have many users, however, you should use an alternate method to return the row you need. Otherwise two users could insert rows at the same time, and thus a conflict could occur with both of them getting back the same max(id). It will not happen often, but at some point it could happen and be very hard to debug. </p>
<p>This handled the uploading of files to the SQL Server via FILESTREAM, in the next installment we’ll look at how to retrieve the file we just uploaded. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arcanecode.wordpress.com/1581/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arcanecode.wordpress.com/1581/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arcanecode.wordpress.com/1581/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arcanecode.wordpress.com/1581/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arcanecode.wordpress.com/1581/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arcanecode.wordpress.com/1581/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arcanecode.wordpress.com/1581/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arcanecode.wordpress.com/1581/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arcanecode.wordpress.com/1581/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arcanecode.wordpress.com/1581/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arcanecode.wordpress.com/1581/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arcanecode.wordpress.com/1581/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arcanecode.wordpress.com/1581/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arcanecode.wordpress.com/1581/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arcanecode.com&#038;blog=340781&#038;post=1581&#038;subd=arcanecode&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arcanecode.com/2009/05/26/accessing-filestream-data-from-a-client-net-application-part-1-uploading-a-file/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8436cd3ff437697b2608405422efa4da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arcanecode</media:title>
		</media:content>

		<media:content url="http://arcanecode.files.wordpress.com/2009/05/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
	</channel>
</rss>
