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

<channel>
	<title>Aneef.Net &#187; SQL</title>
	<atom:link href="http://www.aneef.net/category/tech/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aneef.net</link>
	<description>Do it in .Net way &#124; Blogging about C#,ASP.Net, LINQ,WPF and .Net Technologies</description>
	<lastBuildDate>Mon, 24 May 2010 10:50:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Scott Guthrie Announces the WebsiteSpark Program</title>
		<link>http://www.aneef.net/2009/09/24/scott-guthrie-announces-the-websitespark-program/</link>
		<comments>http://www.aneef.net/2009/09/24/scott-guthrie-announces-the-websitespark-program/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 10:06:43 +0000</pubDate>
		<dc:creator>Aneef Fashir</dc:creator>
				<category><![CDATA[.Net Related]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[visual studio 2008]]></category>
		<category><![CDATA[Expression Blend]]></category>
		<category><![CDATA[ScottGu]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[WebSpark]]></category>

		<guid isPermaLink="false">http://www.aneef.net/?p=104</guid>
		<description><![CDATA[Scott guthrie just did a great announcement about the WebsiteSpark Program. what is WebsiteSpark? WebsiteSpark is designed for independent web developers and web development companies that build web applications and web sites on behalf of others.  It enables you to get software, support and business resources from Microsoft at no cost for three years, and [...]]]></description>
			<content:encoded><![CDATA[<p>Scott guthrie just did a great announcement about the <a href="http://www.microsoft.com/web/websitespark/">WebsiteSpark </a>Program.</p>
<p><strong>what is WebsiteSpark?</strong></p>
<p><span style="font-family: arial; font-size: x-small;"><a href="http://www.microsoft.com/web/websitespark/" target="_blank">WebsiteSpark</a> is designed for independent web developers and web development companies that build web applications and web sites on behalf of others.  It enables you to get software, support and business resources from Microsoft at no cost for three years, and enables you to expand your business and build great web solutions using ASP.NET, Silverlight, SharePoint and PHP, and the <a href="http://www.microsoft.com/web/gallery/default.aspx" target="_blank">open source applications</a> built on top of them.</p>
<h3><span style="text-decoration: underline;">What does the program provide?</span></h3>
<p><a href="http://www.microsoft.com/web/websitespark/" target="_blank">WebSiteSpark</a> provides software licenses that you can use for three years at no cost.  Once enrolled, you can download and immediately use the following software from Microsoft:</p>
<ul>
<li>3 licenses of Visual Studio 2008 Professional Edition</li>
<li>1 license of Expression Studio 3 (which includes Expression Blend, Sketchflow, and Web)</li>
<li>2 licenses of Expression Web 3</li>
<li>4 processor licenses of Windows Web Server 2008 R2</li>
<li>4 processor licenses of SQL Server 2008 Web Edition</li>
<li>DotNetPanel control panel (enabling easy remote/hosted management of your servers)</li>
</ul>
<p>The Windows Server and SQL Server licenses can be used for both development <em>and</em> production deployment.  You can either self-host the servers on your own, or use the licenses with a hoster.  <a href="http://www.microsoft.com/web/websitespark/" target="_blank">WebsiteSpark</a> makes it easy to find hosters who are also enrolled in the program, and who can use your licenses to provide you with either dedicated or virtual dedicated servers to host your sites on.</p>
<p>In addition to software, <a href="http://www.microsoft.com/web/websitespark/" target="_blank">WebsiteSpark</a> provides partner opportunities to grow and build your business (including customer referrals through our partner programs).  It also includes product support (including 2 professional support incidents) and free online training for the products.</p>
<p>for further information on this visit Scotts blog <a href="http://weblogs.asp.net/scottgu/archive/2009/09/24/announcing-the-websitespark-program.aspx">here.</a></p>
<p>Thanks Scott for the great information <img src='http://www.aneef.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p></span></p>
<img src="http://www.aneef.net/?ak_action=api_record_view&id=104&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.aneef.net/2009/09/24/scott-guthrie-announces-the-websitespark-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>100 % CPU SQL Server 2005, Server crashes!</title>
		<link>http://www.aneef.net/2009/04/11/100-cpu-sql-server-2005-servers-crashes/</link>
		<comments>http://www.aneef.net/2009/04/11/100-cpu-sql-server-2005-servers-crashes/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 14:54:27 +0000</pubDate>
		<dc:creator>Aneef Fashir</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tricks & Tips]]></category>

		<guid isPermaLink="false">http://www.aneef.net/2009/04/11/100-cpu-sql-server-2005-servers-crashes/</guid>
		<description><![CDATA[Ah back to my blog. well these days I’m on holidays for Sinhala/ Tamil New year in Sri Lanka. so anyway let met start with wishing all Sinhala  and Tamil Friends A HAPPY NEW YEAR. Lets get back to business, its been a long time since my last post, as usual busy schedules (i know, [...]]]></description>
			<content:encoded><![CDATA[<p>Ah back to my blog. well these days I’m on holidays for Sinhala/ Tamil New year in Sri Lanka. so anyway let met start with wishing all Sinhala  and Tamil Friends A HAPPY NEW YEAR.</p>
<p>Lets get back to business, its been a long time since my last post, as usual busy schedules (i know, i know i tell this often !), but all these days i had several bits and pieces on queue for my blog, and here i am with that.</p>
<p>Last week i had an early morning call from Administrators of  <a href="http://www.catalogues4u.com.au/">Catalogues4u.com.au</a>. they said that the website is running very slow, and users are having connection timeouts in their browsers or poor performance, server logs are filled with SQLConnection Timeout. they have been receiving calls, complaints from their top management, and most of all server restarts. horrible isn’t it?  they have checked the server, and the CPU was running almost 100%, and the culprit which used the most of the CPU was SQL Server.</p>
<p>After spending time in logs, and SQL profiler runs, i found that one stored procedure was taking more time to execute than the others.</p>
<p>here is a part of that SP:</p>
<pre class="csharpcode"><span class="kwrd">SELECT</span>  <span class="kwrd">DISTINCT</span> c.ENDDATE,c.ID, c.NAME,c.THUMBNAILURL,c.CONTENSDESCRIPTION
<span class="kwrd">INTO</span> #temp
<span class="kwrd">FROM</span> GW_CATELOGUE c
 <span class="kwrd">INNER</span> <span class="kwrd">JOIN</span> dbo.GW_CATELOGUE_POSTCODES cp
  <span class="kwrd">ON</span> c.ID=cp.CATELOGUEID
 <span class="kwrd">INNER</span> <span class="kwrd">JOIN</span> dbo.GW_POSTCODES p <span class="kwrd">ON</span> p.Id=cp.POSTCODEID
<span class="kwrd">WHERE</span>  p.POSTCODE=@postcode
 <span class="kwrd">AND</span> (ENDDATE <span class="kwrd">BETWEEN</span> getDate() <span class="kwrd">AND</span> DATEADD(dd, 7, getDate()))
 <span class="kwrd">AND</span> (STARTDATE &lt;= getDate())
 <span class="kwrd">AND</span> (ENDDATE &gt;= getDate())
 <span class="kwrd">AND</span> c.APPROVED=1 <span class="kwrd">ORDER</span> <span class="kwrd">BY</span> c.ENDDATE</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>There were some other SP’s with same structure except the  below Date Filtering which were running perfectly alright:</p>
<pre class="csharpcode"><span class="kwrd">AND</span> (ENDDATE <span class="kwrd">BETWEEN</span> getDate() <span class="kwrd">AND</span> DATEADD(dd, 7, getDate()))</pre>
<pre class="csharpcode"><span class="kwrd">AND</span> (STARTDATE &lt;= getDate()) <span class="kwrd">AND</span> (ENDDATE &gt;= getDate())</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>Well This made me thing something is fishy with the date. with confused mind, and help of MVP <a href="http://dineshpriyankara.spaces.live.com/">Dinesh Priyangara</a> I Created 4 <a href="http://www.sql-server-performance.com/articles/per/index_data_structures_p1.aspx">Non- Clustered Indexes</a> on Catalogue_STARTDATE, Catalogue_ENDDATE and POSTCODE:</p>
<pre class="csharpcode"><span class="kwrd">CREATE</span> <span class="kwrd">INDEX</span> Catalogue_STARTDATE <span class="kwrd">ON</span> GW_CATELOGUE(STARTDATE)
<span class="kwrd">CREATE</span> <span class="kwrd">INDEX</span> Catalogue_ENDDATE <span class="kwrd">ON</span> GW_CATELOGUE(ENDDATE)
<span class="kwrd">CREATE</span> <span class="kwrd">INDEX</span> PostCodes_POSTCODE <span class="kwrd">ON</span> GW_POSTCODES(POSTCODE)</pre>
<pre class="csharpcode"></pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>And Bang!! it worked. server  was back to normal, and everyone was happy. well this might not be a big deal, but still as somebody said, information is wealth!!.</p>
<p><br/><br />
<script type="text/javascript"><!--
google_ad_client = "pub-3530459083226419";
/* linksonly */
google_ad_slot = "6143752371";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script> <br/><br />
<script type="text/javascript"><!--
google_ad_client = "pub-3530459083226419";
/* testadd */
google_ad_slot = "3104422232";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<img src="http://www.aneef.net/?ak_action=api_record_view&id=50&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.aneef.net/2009/04/11/100-cpu-sql-server-2005-servers-crashes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uploading Binary files or Images using LINQ to SQL</title>
		<link>http://www.aneef.net/2009/01/16/uploading-binary-files-or-images-using-linq-to-sql/</link>
		<comments>http://www.aneef.net/2009/01/16/uploading-binary-files-or-images-using-linq-to-sql/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 09:34:34 +0000</pubDate>
		<dc:creator>Aneef Fashir</dc:creator>
				<category><![CDATA[LINQ]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[visual studio 2008]]></category>

		<guid isPermaLink="false">http://www.aneef.net/2009/01/16/uploading-binary-files-or-images-using-linq-to-sql/</guid>
		<description><![CDATA[Today I received an email from a friend, asking how to save a binary file in to the database using LINQ to SQL.  This was the second time a person had asked me the same question, So I thought of having a blog entry about it. Assume that we need to upload a file  and [...]]]></description>
			<content:encoded><![CDATA[<p>Today I received an email from a friend, asking how to save a binary file in to the database using LINQ to SQL.  This was the second time a person had asked me the same question, So I thought of having a blog entry about it.</p>
<p>Assume that we need to upload a file  and save its name, and the file in the database table. so lets see how we do it.</p>
<p><strong>This is my Table</strong></p>
<pre class="csharpcode"><span class="kwrd">CREATE</span> <span class="kwrd">TABLE</span> [dbo].[Files2](
    [ID] [<span class="kwrd">int</span>] <span class="kwrd">IDENTITY</span>(1,1) <span class="kwrd">NOT</span> <span class="kwrd">NULL</span>,
    [FileName] [<span class="kwrd">varchar</span>](50) <span class="kwrd">NOT</span> <span class="kwrd">NULL</span>,
    [FileSource] [image] <span class="kwrd">NOT</span> <span class="kwrd">NULL</span>,
 )
<span class="kwrd">GO</span></pre>
<pre class="csharpcode">And The Following Stored Procedure is used to Insert the Value:</pre>
<pre class="csharpcode"> </pre>
<pre class="csharpcode"><span class="kwrd">CREATE</span> <span class="kwrd">PROCEDURE</span> [dbo].[ADDFILE]
(
    @FILENAME <span class="kwrd">VARCHAR</span>(50),
    @FILESOURCE image
)
<span class="kwrd">AS</span>
<span class="kwrd">SET</span> NOCOUNT <span class="kwrd">ON</span>

INSERT <span class="kwrd">INTO</span> Files([FileName],[FileSource])
<span class="kwrd">VALUES</span>(@FILENAME,@FILESOURCE)</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>And the following code is used to upload and save the file using web form with a text box for file name, and a file upload control to upload the file. on the click event of a button this code is called.</p>
<pre class="csharpcode"><span class="kwrd">protected</span> <span class="kwrd">void</span> Button1_Click(<span class="kwrd">object</span> sender, EventArgs e)
{

     <span class="kwrd">if</span> (FileUploader.HasFile &amp;&amp; FileUploader.PostedFile.ContentLength &gt; 0)
      {
          <span class="kwrd">string</span> filename = txtFileName.Text;
          <span class="rem">//Read the file in to a byte Array.</span>
          <span class="kwrd">byte</span>[] filebyte = FileUploader.FileBytes;

    System.Data.Linq.Binary fileBinary = <span class="kwrd">new</span> System.Data.Linq.Binary(filebyte);
          MyDataDataContext MyData = <span class="kwrd">new</span> MyDataDataContext();

          MyData.ADDFILE(filename, fileBinary);
          lblStatus.Text = <span class="str">"File Uploaded Successfully!"</span>;

        }
}</pre>
<pre class="csharpcode"> </pre>
<pre class="csharpcode"> </pre>
<p>The Main thing to remember here is that we need to pass the FileUploader.FileBytes  to the constructor of <a href="http://msdn.microsoft.com/en-us/library/system.data.linq.binary.aspx" target="_blank">System.Data.Linq.Binary</a>.</p>
<p>To Learn more about LINQ to SQL Please visit <a href="http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx" target="_blank">Here</a>.</p>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<pre class="csharpcode"><strong><em> EDIT:</em></strong><em> Richie </em><em>just showed another way to achieve this in his blog </em><a href="http://hengrr.wordpress.com/2009/02/20/linq-to-sql-upload-binary-file/" target="_blank"><em>here</em></a><em>.</em></pre>
<pre class="csharpcode"> </pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p><!--adsense#InPostImage--></p>
<img src="http://www.aneef.net/?ak_action=api_record_view&id=39&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.aneef.net/2009/01/16/uploading-binary-files-or-images-using-linq-to-sql/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>The FILESTREAM Data Type in SQL Server 2008</title>
		<link>http://www.aneef.net/2008/09/24/the-filestream-data-type-in-sql-server-2008/</link>
		<comments>http://www.aneef.net/2008/09/24/the-filestream-data-type-in-sql-server-2008/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 09:39:32 +0000</pubDate>
		<dc:creator>Aneef Fashir</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.aneef.net/?p=36</guid>
		<description><![CDATA[Seriously, i&#8217;ve no time these days for blogging, busy with work as well as personal activities. but just wanted to share this valuable information for those who might have missed. Well the current project which im working on is the ASSETTE Presentations. for more information on the project you can see the above link. but [...]]]></description>
			<content:encoded><![CDATA[<p>Seriously, i&#8217;ve no time these days for blogging, busy with work as well as personal activities. but just wanted to share this valuable information for those who might have missed.</p>
<p>Well the current project which im working on is the <a title="Assette Presentations" href="http://www.assette.com/ProductPresentation.asp" target="_blank">ASSETTE Presentations</a>. for more information on the project you can see the above link. but the project uses alot of binary data transfered back and forth to the server and the client thorugh our web services, and most of these binary files are stored in SQL Server 2005 Database. storing binary files inside the database really slows down retrieval of the files when we need them and there are several other desadvantages also. specially  rapidly growing size of the database,taking backups, and maintainance of the database. </p>
<p>But now with SQL Server 2008 we have a new data type called <a title="FileStream" href="http://www.microsoft.com/sqlserver/2008/en/us/wp-sql-2008-manage-unstructured.aspx" target="_blank">FILESTREAM</a> , to solve all the above issues.</p>
<p> </p>
<p><strong style="font-weight: bold;">What is FILESTREAM?</strong></p>
<p>FILESTREAM is a new datatype in SQL SERVER 2008. To use FILESTREAM, a database needs to contain a FILESTREAM filegroup and a table which contains a varbinary(max) column with the FILESTREAM attribute set. This causes the Database Engine to store all data for that column in the file system, but not in the database file. A FILESTREAM filegroup is a special folder that contains file system directories known as <strong style="font-weight: bold;">data containers</strong>. These data containers are the interface between Database Engine storage and file system storage through which files in these data containers are maintained by Database Engine.</p>
<p><strong style="font-weight: bold;">What FILESTREAM</strong> <strong style="font-weight: bold;">does?</strong></p>
<p>By creating a FILESTREAM filegroup and setting a FILESTREAM attribute on the column of a table, a data container is created which will take care of DML statements.</p>
<p>FILESTREAM will use Windows API for streaming the files so that files can be accessed faster. Also instead of using SQL SERVER cache it will use Windows cache for caching the files accessed.</p>
<p>When you use FILESTREAM storage, consider the following:</p>
<ul>
<li>When a table contains a FILESTREAM column, each row must have a unique row ID.</li>
<li>FILESTREAM data containers cannot be nested.</li>
<li>When you are using failover clustering, the FILESTREAM filegroups must be on shared disk resources.</li>
<li>FILESTREAM filegroups can be on compressed volumes.</li>
</ul>
<div>For more information on how to use FILESTREAM and to have a in depth knowladge about it please refer the below article in <a href="http://www.sqlservercentral.com/articles/SQL+Server+2008/64088/" target="_blank">SQLSERVERCENTRA</a><a href="http://www.sqlservercentral.com/articles/SQL+Server+2008/64088/" target="_blank">L</a>. its well written and gives you a clear idea on what it is.</div>
<div><strong style="font-weight: bold;"><a href="http://www.sqlservercentral.com/articles/SQL+Server+2008/64088/" target="_blank">The FILESTREAM Data Type in SQL Server 2008</a></strong></div>
<div>
<div><strong style="font-weight: bold;"><span style="color: #993366;"><a href="http://www.sqlservercentral.com/Authors/Articles/Deepa_Gheewala/231169/" target="_blank">By Deepa Gheewala</a></span></strong>, 2008/09/24</div>
</div>
<div>and <a href="http://blogs.msdn.com/rdoherty/archive/2007/10/12/getting-traction-with-sql-server-2008-filestream.aspx" target="_blank">here </a>is another blog post on the same topic in MSDN Blogs.</div>
<div>Hope It helps!.</div>
<p> </p>
<p> </p>
<img src="http://www.aneef.net/?ak_action=api_record_view&id=36&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.aneef.net/2008/09/24/the-filestream-data-type-in-sql-server-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2008 Table Valued Parameters</title>
		<link>http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/</link>
		<comments>http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/#comments</comments>
		<pubDate>Sun, 23 Dec 2007 15:36:13 +0000</pubDate>
		<dc:creator>Aneef Fashir</dc:creator>
				<category><![CDATA[ADO.net]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[visual studio 2008]]></category>
		<category><![CDATA[OPENXML]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[Table Valued Parameters]]></category>
		<category><![CDATA[UDT]]></category>

		<guid isPermaLink="false">http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/</guid>
		<description><![CDATA[Last two weeks I have been working on developing bulk data manipulations. And even before that I always wondered “What&#8217;s the best way to pass an array of values into a SQL Server stored procedure.” One option I found was OPENXML, which I blogged here. And I was trying out visual studio 2008 and SQL [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal"><span>Last two weeks I have been working on developing bulk data manipulations. And even before that I always wondered “</span>What&#8217;s the best way to pass an array of values into a SQL Server stored procedure.” One option I found was <a href="http://www.aneef.net/2007/12/18/adonet-openxml-to-perform-bulk-database-operations/">OPENXML</a>, which I blogged <a href="http://www.aneef.net/2007/12/18/adonet-openxml-to-perform-bulk-database-operations/">here</a>.</p>
<p><!--adsense#largebox--></p>
<p class="MsoNormal">
<p>And I was trying out visual studio 2008 and SQL server 2008 these days. And last night I found out that SQL server now support Tabled valued Parameters which allow us to send data tables as parameters to stored procedures. It still uses the same ADO.Net API.</p>
<p class="MsoNormal">Now I’m going to show how it works. For this I’m using the same scenario which I used in my <a href="http://www.aneef.net/2007/12/18/adonet-openxml-to-perform-bulk-database-operations/">previous post</a> (reading contents of a folder and saving their information). here i have used <a href="http://www.microsoft.com/sql/2008/default.mspx" target="_blank">sql server 2008 november ctp</a> and <a href="http://www.microsoft.com/express/vcsharp/Default.aspx">visual  c# 2008 express edition</a>.</p>
<p class="MsoNormal">First create the table given below:</p>
<blockquote>
<h5><em><span style="font-family: 'Cambria','serif'; color: blue">CREATE TABLE</span></em><em><span style="font-family: 'Cambria','serif'"> FileDetails(<br />
FileName varchar(50) </span></em><em><span style="font-family: 'Cambria','serif'; color: blue">PRIMARY KEY</span></em><em><span style="font-family: 'Cambria','serif'">,<br />
CreatedDate varchar(50) ,<br />
Size </span></em><em><span style="font-family: 'Cambria','serif'; color: blue">decimal</span></em><em><span style="font-family: 'Cambria','serif'">(18, 0) )</span></em></h5>
</blockquote>
<p class="MsoNormal">
<p class="MsoNormal">
<p><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves /> <w:TrackFormatting /> <w:PunctuationKerning /> <w:ValidateAgainstSchemas /> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF /> <w:LidThemeOther>EN-US</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables /> <w:SnapToGridInCell /> <w:WrapTextWithPunct /> <w:UseAsianBreakRules /> <w:DontGrowAutofit /> <w:SplitPgBreakAndParaMark /> <w:DontVertAlignCellWithSp /> <w:DontBreakConstrainedForcedTables /> <w:DontVertAlignInTxbx /> <w:Word11KerningPairs /> <w:CachedColBalance /> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math" /> <m:brkBin m:val="before" /> <m:brkBinSub m:val=" " /> <m:smallFrac m:val="off" /> <m:dispDef /> <m:lMargin m:val="0" /> <m:rMargin m:val="0" /> <m:defJc m:val="centerGroup" /> <m:wrapIndent m:val="1440" /> <m:intLim m:val="subSup" /> <m:naryLim m:val="undOvr" /> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"   DefSemiHidden="true" DefQFormat="false" DefPriority="99"   LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Normal" /> <w:LsdException Locked="false" Priority="9" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="heading 1" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9" /> <w:LsdException Locked="false" Priority="39" Name="toc 1" /> <w:LsdException Locked="false" Priority="39" Name="toc 2" /> <w:LsdException Locked="false" Priority="39" Name="toc 3" /> <w:LsdException Locked="false" Priority="39" Name="toc 4" /> <w:LsdException Locked="false" Priority="39" Name="toc 5" /> <w:LsdException Locked="false" Priority="39" Name="toc 6" /> <w:LsdException Locked="false" Priority="39" Name="toc 7" /> <w:LsdException Locked="false" Priority="39" Name="toc 8" /> <w:LsdException Locked="false" Priority="39" Name="toc 9" /> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption" /> <w:LsdException Locked="false" Priority="10" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Title" /> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font" /> <w:LsdException Locked="false" Priority="11" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtitle" /> <w:LsdException Locked="false" Priority="22" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Strong" /> <w:LsdException Locked="false" Priority="20" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Emphasis" /> <w:LsdException Locked="false" Priority="59" SemiHidden="false"    UnhideWhenUsed="false" Name="Table Grid" /> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text" /> <w:LsdException Locked="false" Priority="1" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="No Spacing" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 1" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 1" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 1" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 1" /> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision" /> <w:LsdException Locked="false" Priority="34" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="List Paragraph" /> <w:LsdException Locked="false" Priority="29" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Quote" /> <w:LsdException Locked="false" Priority="30" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Quote" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 1" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 1" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 1" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 1" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 1" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 2" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 2" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 2" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 2" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 2" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 2" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 2" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 2" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 2" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 3" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 3" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 3" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 3" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 3" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 3" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 3" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 3" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 3" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 4" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 4" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 4" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 4" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 4" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 4" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 4" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 4" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 4" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 5" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 5" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 5" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 5" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 5" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 5" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 5" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 5" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 5" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 6" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 6" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 6" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 6" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 6" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 6" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 6" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 6" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 6" /> <w:LsdException Locked="false" Priority="19" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis" /> <w:LsdException Locked="false" Priority="21" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis" /> <w:LsdException Locked="false" Priority="31" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference" /> <w:LsdException Locked="false" Priority="32" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Reference" /> <w:LsdException Locked="false" Priority="33" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Book Title" /> <w:LsdException Locked="false" Priority="37" Name="Bibliography" /> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading" /> </w:LatentStyles> </xml><![endif]--></p>
<p><!--   /* Font Definitions */  @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:1; 	mso-generic-font-family:roman; 	mso-font-format:other; 	mso-font-pitch:variable; 	mso-font-signature:0 0 0 0 0 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin-top:0in; 	margin-right:0in; 	margin-bottom:10.0pt; 	margin-left:0in; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} .MsoPapDefault 	{mso-style-type:export-only; 	margin-bottom:10.0pt; 	line-height:115%;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.0in 1.0in 1.0in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --></p>
<p><!--[if gte mso 10]></p>
<p><mce:style><!    /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-qformat:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin-top:0in; 	mso-para-margin-right:0in; 	mso-para-margin-bottom:10.0pt; 	mso-para-margin-left:0in; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-theme-font:minor-fareast; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin;}  --></p>
<p><!--[endif]--></p>
<p class="MsoNormal">Then, we should declare a new Table User Defined Type in the database:</p>
<blockquote>
<p class="MsoNormal">create type FileDetailsType as table<br />
(<br />
<span> </span><span> </span>FileName<span> </span>varchar(50),<br />
<span> </span>CreatedDate<span> </span>varchar(50),<br />
<span> </span>Size<span> </span>decimal(18,0)<br />
)</p></blockquote>
<p class="MsoNormal">
<p class="MsoNormal">
<p><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves /> <w:TrackFormatting /> <w:PunctuationKerning /> <w:ValidateAgainstSchemas /> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF /> <w:LidThemeOther>EN-US</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables /> <w:SnapToGridInCell /> <w:WrapTextWithPunct /> <w:UseAsianBreakRules /> <w:DontGrowAutofit /> <w:SplitPgBreakAndParaMark /> <w:DontVertAlignCellWithSp /> <w:DontBreakConstrainedForcedTables /> <w:DontVertAlignInTxbx /> <w:Word11KerningPairs /> <w:CachedColBalance /> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math" /> <m:brkBin m:val="before" /> <m:brkBinSub m:val=" " /> <m:smallFrac m:val="off" /> <m:dispDef /> <m:lMargin m:val="0" /> <m:rMargin m:val="0" /> <m:defJc m:val="centerGroup" /> <m:wrapIndent m:val="1440" /> <m:intLim m:val="subSup" /> <m:naryLim m:val="undOvr" /> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"   DefSemiHidden="true" DefQFormat="false" DefPriority="99"   LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Normal" /> <w:LsdException Locked="false" Priority="9" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="heading 1" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9" /> <w:LsdException Locked="false" Priority="39" Name="toc 1" /> <w:LsdException Locked="false" Priority="39" Name="toc 2" /> <w:LsdException Locked="false" Priority="39" Name="toc 3" /> <w:LsdException Locked="false" Priority="39" Name="toc 4" /> <w:LsdException Locked="false" Priority="39" Name="toc 5" /> <w:LsdException Locked="false" Priority="39" Name="toc 6" /> <w:LsdException Locked="false" Priority="39" Name="toc 7" /> <w:LsdException Locked="false" Priority="39" Name="toc 8" /> <w:LsdException Locked="false" Priority="39" Name="toc 9" /> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption" /> <w:LsdException Locked="false" Priority="10" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Title" /> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font" /> <w:LsdException Locked="false" Priority="11" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtitle" /> <w:LsdException Locked="false" Priority="22" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Strong" /> <w:LsdException Locked="false" Priority="20" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Emphasis" /> <w:LsdException Locked="false" Priority="59" SemiHidden="false"    UnhideWhenUsed="false" Name="Table Grid" /> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text" /> <w:LsdException Locked="false" Priority="1" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="No Spacing" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 1" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 1" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 1" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 1" /> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision" /> <w:LsdException Locked="false" Priority="34" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="List Paragraph" /> <w:LsdException Locked="false" Priority="29" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Quote" /> <w:LsdException Locked="false" Priority="30" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Quote" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 1" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 1" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 1" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 1" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 1" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 2" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 2" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 2" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 2" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 2" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 2" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 2" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 2" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 2" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 3" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 3" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 3" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 3" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 3" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 3" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 3" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 3" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 3" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 4" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 4" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 4" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 4" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 4" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 4" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 4" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 4" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 4" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 5" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 5" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 5" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 5" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 5" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 5" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 5" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 5" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 5" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 6" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 6" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 6" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 6" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 6" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 6" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 6" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 6" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 6" /> <w:LsdException Locked="false" Priority="19" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis" /> <w:LsdException Locked="false" Priority="21" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis" /> <w:LsdException Locked="false" Priority="31" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference" /> <w:LsdException Locked="false" Priority="32" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Reference" /> <w:LsdException Locked="false" Priority="33" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Book Title" /> <w:LsdException Locked="false" Priority="37" Name="Bibliography" /> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading" /> </w:LatentStyles> </xml><![endif]--><br />
<!--   /* Font Definitions */  @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:1; 	mso-generic-font-family:roman; 	mso-font-format:other; 	mso-font-pitch:variable; 	mso-font-signature:0 0 0 0 0 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin-top:0in; 	margin-right:0in; 	margin-bottom:10.0pt; 	margin-left:0in; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} .MsoPapDefault 	{mso-style-type:export-only; 	margin-bottom:10.0pt; 	line-height:115%;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 27.0pt 1.0in 1.0in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --></p>
<p><!--[if gte mso 10]></p>
<p><mce:style><!    /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-qformat:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin-top:0in; 	mso-para-margin-right:0in; 	mso-para-margin-bottom:10.0pt; 	mso-para-margin-left:0in; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-theme-font:minor-fareast; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin;}  --></p>
<p><!--[endif]--></p>
<p class="MsoNormal">Then create a stored procedure that gets a parameter of the above type, and inserts many rows in a single command.</p>
<blockquote>
<p class="MsoNormal">create procedure InsertFileDetails<br />
(<br />
<span> </span><span> </span>@FileDetails FileDetailsType readonly<br />
)<br />
as</p>
<p class="MsoNormal"><span> </span>insert<br />
<span> </span>into<span> </span>FileDetails (FileName, CreatedDate, Size)<br />
<span> </span>select FileName, CreatedDate, Size<br />
<span> </span>from<span> </span>@FileDetails;</p></blockquote>
<p class="MsoNormal">
<p class="MsoNormal">
<p class="MsoNormal">Then to execute this procedure, we can create a data table and add the rows in to it. And then pass this data table as parameter to the database.</p>
<blockquote>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'; color: blue">private</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">static</span> <span style="color: blue">void</span> SaveFileDetail(<span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">FileInfo</span>&gt; info)</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span><span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">&#8220;**********updating with tablevalued parameters****&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span><span style="color: #2b91af">DataTable</span> dt = preparedatatable();</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span><span style="color: blue">foreach</span> (<span style="color: #2b91af">FileInfo</span> file <span style="color: blue">in</span> info)</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span><span style="color: #2b91af">DataRow</span> dr = dt.NewRow();</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span><span> </span>dr[0] = file.Name;</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span>dr[1] = file.CreationTime.ToShortDateString();</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span>dr[2] = (<span style="color: blue">decimal</span>)file.Length;</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span>dt.Rows.Add(dr);<span> </span></span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span><span style="color: blue">using</span> (<span style="color: #2b91af">SqlConnection</span> conn = <span style="color: blue">new</span> <span style="color: #2b91af">SqlConnection</span>(<span style="color: #a31515">&#8220;your connection string&#8221;</span>))</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span><span style="color: #2b91af">SqlCommand</span> cmd = conn.CreateCommand();</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span>cmd.CommandType = System.Data.<span style="color: #2b91af">CommandType</span>.StoredProcedure;</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span>cmd.CommandText = <span style="color: #a31515">&#8220;dbo.InsertFileDetails&#8221;</span>;</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span><span style="color: #2b91af">SqlParameter</span> param = cmd.Parameters.AddWithValue(<span style="color: #a31515">&#8220;@FileDetails&#8221;</span>, dt);<span> </span></span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span>conn.Open();</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span>cmd.ExecuteNonQuery();</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Courier New'"><span> </span><span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">&#8220;Completed Updating the database&#8221;</span>);</span><span style="font-size: 10pt; line-height: 115%; font-family: 'Courier New'"><span> </span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: 'Courier New'"><span> </span>}</span></p>
</blockquote>
<p class="MsoNormal">
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: 'Courier New'"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: 'Courier New'">Now that’s cool isn’t it????</span></p>
<p class="MsoNormal">
<p class="MsoNormal"><strong><a title="source code" href="http://www.aneef.net/wp-content/uploads/2007/12/tblvalueparam.zip" target="_blank">Download the code </a></strong></p>
<img src="http://www.aneef.net/?ak_action=api_record_view&id=11&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>ADO.Net &amp; OPENXML to Perform Bulk Database Operations</title>
		<link>http://www.aneef.net/2007/12/18/adonet-openxml-to-perform-bulk-database-operations/</link>
		<comments>http://www.aneef.net/2007/12/18/adonet-openxml-to-perform-bulk-database-operations/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 05:36:37 +0000</pubDate>
		<dc:creator>Aneef Fashir</dc:creator>
				<category><![CDATA[ADO.net]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[Aneef]]></category>
		<category><![CDATA[BULK Data manipulation]]></category>

		<guid isPermaLink="false">http://www.aneef.net/?p=7</guid>
		<description><![CDATA[Last week at my work I had to write a tool to process few hundreds of thousand email files and insert their details to the MS SQL Server 2005 database. Doing it in traditional way might require much connectivity to the database and will consume many resources. I was wondering what if I could insert [...]]]></description>
			<content:encoded><![CDATA[<p>Last week at my work I had to write a tool to process few hundreds of thousand email files and insert their details to the MS SQL Server 2005 database. Doing it in traditional way might require much connectivity to the database and will consume many resources. I was wondering what if I could insert those whole hundreds thousands of data at once to the db which will be much more efficient. I started googgling and I found <a href="http://msdn2.microsoft.com/en-us/library/aa276847.aspx">OPENXML</a>. This is not a whole new technology but I didn’t know about this before (strange!!).</p>
<p>And few more minutes of research I found out how to perform bulk operations against the databases using OPENXML and stored procedures.</p>
<p><strong>What is OPENXML?</strong></p>
<p>OPENXML is a function added to SQL Server 2000 that provides a row set view over an XML document. Since a row set is simply a set of rows that contain columns of data, OPENXML is the function that allows an XML document to be treated in the familiar relational database format. It allows for the passing of an XML document to a T-SQL stored procedure for updating the data.</p>
<p><strong>OPENXML- Summery</strong></p>
<ul>
<li>It extends the SQL Language</li>
<li>It is used within T-SQL Stored Procedures
<ul>
<li>XML Document passed as parameter</li>
</ul>
</li>
<li>It uses row and column selectors utilizing XPath</li>
<li>It supports the following:
<ul>
<li>Attribute and element-centric mappings.</li>
<li>Edge table row set.</li>
<li>XML annotation/overflow column.</li>
<li>Hierarchy support.</li>
</ul>
</li>
</ul>
<p><strong>OPENXML and ADO.Net</strong></p>
<p>This code block explains the usage of OPENXML to insert bulk data to database. It simulates the actual process I wanted ( processing .eml files) by reading files in a folder and saving their names, created date and size in bytes.</p>
<ol>
<li>First create the table below:<br />
<h5></h5>
<h6></h6>
<blockquote>
<h5><em><font color="#0000ff">CREATE TABLE</font> FileDetails(</em></h5>
<h5><em>FileName varchar(50) <font color="#0000ff">PRIMARY KEY</font>,</em></h5>
<h5><em>CreatedDate varchar(50) ,</em></h5>
<h5><em>Size <font color="#0000ff">decimal</font>(18, 0) )</em></h5>
</blockquote>
</li>
<li>And then create the stored procedure below:<br />
<blockquote>
<h5><em><font color="#0000ff"><em><font color="#0000ff"><em><font color="#0000ff">CREATE PROC</font> sp_bulkinsert @xmldata varchar(max)</em></font></em></font></em></h5>
<h5><font color="#0000ff"><em>AS</em></font></h5>
<h5><em><font color="#0000ff">DECLARE</font> @hDoc int</em></h5>
<h5><em><font color="#0000ff">exec</font> sp_xml_preparedocument @hDoc OUTPUT,@xmldata</em></h5>
<h5><em>&#8211;inserting data</em></h5>
<h5><em><font color="#0000ff">Insert</font> Into FileDetails </em></h5>
<h5><em><font color="#0000ff">SELECT</font> FileName, CreatedDate, Size</em></h5>
<h5><em><font color="#0000ff">FROM</font> OPENXML (@hdoc, &#8216;/ds/fileDetails&#8217;,2)</em></h5>
<h5><em><font color="#0000ff">WITH</font> (FileName varchar(50), CreatedDate Datetime, Size decimal) XMLFileDetails</em></h5>
<h5><em><font color="#0000ff">Where</font> XMLFileDetails.FileName Not IN (Select FileName from FileDetails)</em></h5>
<h5><em><font color="#0000ff">EXEC</font> sp_xml_removedocument @hDoc</em></h5>
<h5><font color="#0000ff"><em>GO</em></font></h5>
</blockquote>
</li>
<li>The below sample code snippet shows how to call this stored procedure to insert bulk data to database at once.</li>
</ol>
<ol>We can retrieve the file details using FileInfo() objects and create a Dataset of the file details and then we can convert this Dataset to xml using <a href="http://msdn2.microsoft.com/en-us/library/system.data.dataset.writexml.aspx">WriteXml()</a> Method of the Dataset.</ol>
<blockquote><p><em>private static string preparexml(DataSet ds)</em></p>
<p><em>{</em></p>
<p><em>StringBuilder sb = new StringBuilder();</em></p>
<p><em>StringWriter sw = new StringWriter(sb);</em></p>
<p><em>ds.WriteXml(sw, XmlWriteMode.WriteSchema);</em></p>
<p><em>return sb.ToString();</em></p>
<p><em>}</em></p></blockquote>
<p>This xml representation of the data can be passed as the parameter to the stored procedure as given below :</p>
<blockquote><p><code><em>private static void bulkInsert(string xml)</em> </code></p>
<p><em>{</em></p>
<p><em>try{</em></p>
<p><em>SqlConnection con = creatCon();</em></p>
<p><em>con.Open();</em></p>
<p><em>SqlCommand cmd = new SqlCommand(&#8220;sp_bulkinsert&#8221;, con);</em></p>
<p><em>cmd.CommandType = CommandType.StoredProcedure;</em></p>
<p><em>cmd.Parameters.Add(new SqlParameter(&#8220;@xmldata&#8221;,SqlDbType.VarChar));</em></p>
<p><em>cmd.Parameters["@xmldata"].Value=xml;</em></p>
<p><em>cmd.ExecuteNonQuery();</em></p>
<p><em>Console.WriteLine(&#8220;Completed inserting file informations to database&#8221;);</em></p>
<p><em>con.Close();</em></p>
<p><em>}</em></p>
<p><em>catch(Exception ex)</em></p>
<p><em>{</em></p>
<p><em>Console.WriteLine(ex.Message);</em></p>
<p><em>}</em></p>
<p><em>}</em></p></blockquote>
<p>That’s all simple isn’t it? You can see the performance of this method by writing another code to insert the same fields using the traditional 1 at a time way. Which surprisingly will show a huge difference in performance and time.</p>
<p>You can use the same way to update, delete records in bulk.</p>
<p>The complete code can be downloaded and tested in the below link :</p>
<p><a href="http://www.aneef.net/wp-content/uploads/2007/12/bulkoperations.zip">Complete Source Code</a></p>
<p><!--adsense--></p>
<img src="http://www.aneef.net/?ak_action=api_record_view&id=7&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.aneef.net/2007/12/18/adonet-openxml-to-perform-bulk-database-operations/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
