<?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>This part of my life is called: Being Myself &#187; SQL Server</title>
	<atom:link href="http://balajiramesh.wordpress.com/category/sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://balajiramesh.wordpress.com</link>
	<description>A .Net web developers blog!</description>
	<lastBuildDate>Tue, 13 Jan 2009 06:27:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='balajiramesh.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/c73b09615ef01255a5304afb9f765d0c?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>This part of my life is called: Being Myself &#187; SQL Server</title>
		<link>http://balajiramesh.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://balajiramesh.wordpress.com/osd.xml" title="This part of my life is called: Being Myself" />
	<atom:link rel='hub' href='http://balajiramesh.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Query for Powers of 2 in SQL Server 2005</title>
		<link>http://balajiramesh.wordpress.com/2008/08/14/query-for-powers-of-2-in-sql-server-2005/</link>
		<comments>http://balajiramesh.wordpress.com/2008/08/14/query-for-powers-of-2-in-sql-server-2005/#comments</comments>
		<pubDate>Thu, 14 Aug 2008 18:28:53 +0000</pubDate>
		<dc:creator>Balaji Ramesh</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://balajiramesh.wordpress.com/2008/08/14/query-for-powers-of-2-in-sql-server-2005/</guid>
		<description><![CDATA[I had a table with two columns: ID and Description. The task was to display the description of all elements whose ID is a power of two. Here&#8217;s the query that let me accomplish that:
SELECT ID, Desc FROM tblBits WHERE ID &#62; 0 AND ID &#38; (ID-1) = 0
How does this work?
Every power of two [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=60&subd=balajiramesh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I had a table with two columns: ID and Description. The task was to display the description of all elements whose ID is a power of two. Here&#8217;s the query that let me accomplish that:</p>
<p><strong>SELECT ID, Desc FROM tblBits WHERE ID &gt; 0 AND ID &amp; (ID-1) = 0</strong></p>
<p>How does this work?</p>
<p>Every power of two when converted to binary has only one bit set.<br />For example: 4=100, 8=1000, 16=10000<br />And one digit less in binary looks like:<br />3 = 011, 7=0111, 15=01111</p>
<p>So an AND operation between {4,3}, {8,7}, {16,15} and so on will always yield a &#8216;0&#8242;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/balajiramesh.wordpress.com/60/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/balajiramesh.wordpress.com/60/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/balajiramesh.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/balajiramesh.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/balajiramesh.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/balajiramesh.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/balajiramesh.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/balajiramesh.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/balajiramesh.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/balajiramesh.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/balajiramesh.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/balajiramesh.wordpress.com/60/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=60&subd=balajiramesh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://balajiramesh.wordpress.com/2008/08/14/query-for-powers-of-2-in-sql-server-2005/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a8706fb30f1c3933f690857a5200006a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">balajiramesh</media:title>
		</media:content>
	</item>
		<item>
		<title>Computed Columns in SQL Server 2005</title>
		<link>http://balajiramesh.wordpress.com/2008/06/05/computed-columns-in-sql-server-2005/</link>
		<comments>http://balajiramesh.wordpress.com/2008/06/05/computed-columns-in-sql-server-2005/#comments</comments>
		<pubDate>Thu, 05 Jun 2008 11:27:41 +0000</pubDate>
		<dc:creator>Balaji Ramesh</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Computed Column]]></category>
		<category><![CDATA[Management Studio]]></category>
		<category><![CDATA[Persisted]]></category>

		<guid isPermaLink="false">http://balajiramesh.wordpress.com/2008/06/05/computed-columns-in-sql-server-2005/</guid>
		<description><![CDATA[Using Persited Columns in SQL Server 2005 via t-sql and sql server management studio<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=51&subd=balajiramesh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>&#8220;Computed Columns&#8221; as the name suggests allows you to set the value of a column based on other columns data. Here&#8217;s how you could specify the formula in T-SQL: </p>
<pre>--Create Table
<span class="kwrd">CREATE</span> <span class="kwrd">TABLE</span> T1 (
    a <span class="kwrd">INT</span>,
    b <span class="kwrd">INT</span>,
    operator <span class="kwrd">CHAR</span>,
    c <span class="kwrd">AS</span> <span class="kwrd">CASE</span> operator
        <span class="kwrd">WHEN</span> <span class="str">'+'</span> <span class="kwrd">THEN</span> a+b
        <span class="kwrd">WHEN</span> <span class="str">'-'</span> <span class="kwrd">THEN</span> a-b
        <span class="kwrd">ELSE</span> a*b
    <span class="kwrd">END</span>
    PERSISTED
) ;

--Insert dummy data into it
<span class="kwrd">INSERT INTO</span> T1 <span class="kwrd">VALUES</span>(1,2,<span class="str">'+'</span>)
<span class="kwrd">INSERT INTO</span> T1 <span class="kwrd">VALUES</span>(5,3,<span class="str">'-'</span>)
<span class="kwrd">INSERT INTO</span> T1 <span class="kwrd">VALUES</span>(4,4,<span class="str">''</span>)

--View the results
<span class="kwrd">SELECT</span> * <span class="kwrd">FROM</span> T1</pre>
<p>Notice the keyword <strong>PERSISTED</strong>. This will enable the computed column value to be stored physically on to the disk so that it need not be created every time you ask for it. Creating an index on this computed column will improve performance by doing a seek rather than a table scan.</p>
<p>If you want to specify the above computed column in <strong>SQL Server management studio </strong>directly you can do this:</p>
<p>Modify the table. Go to the computed column specification for the specific column. Expand it and type the following in the &#8220;Formula&#8221; field:</p>
<pre>(<span class="kwrd">CASE</span> [operator] <span class="kwrd">WHEN</span> <span class="str">'+'</span> <span class="kwrd">THEN</span> [a]+[b] <span class="kwrd">WHEN</span> <span class="str">'-'</span> <span class="kwrd">THEN</span> [a]-[b]

<span class="kwrd">ELSE</span> [a]*[b] <span class="kwrd">END</span>)</pre>
<p>Enter without line breaks. If you want the column values to be persisted in the storage medium, just change the value of &#8220;Is Persisted&#8221; to &#8220;Yes&#8221;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/balajiramesh.wordpress.com/51/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/balajiramesh.wordpress.com/51/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/balajiramesh.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/balajiramesh.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/balajiramesh.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/balajiramesh.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/balajiramesh.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/balajiramesh.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/balajiramesh.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/balajiramesh.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/balajiramesh.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/balajiramesh.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=51&subd=balajiramesh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://balajiramesh.wordpress.com/2008/06/05/computed-columns-in-sql-server-2005/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a8706fb30f1c3933f690857a5200006a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">balajiramesh</media:title>
		</media:content>
	</item>
		<item>
		<title>Concatenating column values in SQL Server 2000/2005</title>
		<link>http://balajiramesh.wordpress.com/2008/04/14/concatenating-column-values-in-sql-server-20002005/</link>
		<comments>http://balajiramesh.wordpress.com/2008/04/14/concatenating-column-values-in-sql-server-20002005/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 10:02:37 +0000</pubDate>
		<dc:creator>Balaji Ramesh</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://balajiramesh.wordpress.com/2008/04/14/concatenating-column-values-in-sql-server-20002005/</guid>
		<description><![CDATA[If you want to concatenate values from a specific column like for example: 
Table=====1&#160;&#160;&#160; One2&#160;&#160;&#160; Two3&#160;&#160;&#160; Three4&#160;&#160;&#160; Four

to the following:
Output======One, Two, Three, Four

Here is a simple way to do it:
SQL Server 2005: 
SELECT STUFF(SELECT &#8216;, &#8216; + ColumnName FROM TableName FOR XML PATH(&#8221;),1,2,&#8221;)

SQL Server 2000:
DECLARE @t varchar(4000)SET @t = &#8221;SELECT @t = @t + &#8216;, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=45&subd=balajiramesh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>If you want to concatenate values from a specific column like for example: </p>
<blockquote><p>Table<br />=====<br />1&nbsp;&nbsp;&nbsp; One<br />2&nbsp;&nbsp;&nbsp; Two<br />3&nbsp;&nbsp;&nbsp; Three<br />4&nbsp;&nbsp;&nbsp; Four</p>
</blockquote>
<p><font color="#000000">to the following:</font></p>
<blockquote><p><font color="#777777">Output<br />======<br />One, Two, Three, Four</font></p>
</blockquote>
<p><font color="#000000">Here is a simple way to do it:</font></p>
<p><font color="#777777"><font color="#000000"><strong>SQL Server 2005</strong>:</font> </font></p>
<blockquote><p>SELECT STUFF(SELECT &#8216;, &#8216; + ColumnName FROM TableName FOR XML PATH(&#8221;),1,2,&#8221;)</p>
</blockquote>
<p><strong>SQL Server 2000</strong>:</p>
<blockquote><p>DECLARE @t varchar(4000)<br />SET @t = &#8221;<br />SELECT @t = @t + &#8216;, &#8216; + ColumnName From TableName<br />SELECT STUFF(@t,1,2,&#8221;)</p>
</blockquote>
<p>STUFF() deletes a specified length of characters and inserts another set of characters at a specified starting point.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/balajiramesh.wordpress.com/45/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/balajiramesh.wordpress.com/45/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/balajiramesh.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/balajiramesh.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/balajiramesh.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/balajiramesh.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/balajiramesh.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/balajiramesh.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/balajiramesh.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/balajiramesh.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/balajiramesh.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/balajiramesh.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=45&subd=balajiramesh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://balajiramesh.wordpress.com/2008/04/14/concatenating-column-values-in-sql-server-20002005/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a8706fb30f1c3933f690857a5200006a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">balajiramesh</media:title>
		</media:content>
	</item>
		<item>
		<title>Convert column data from Binary to String with SQL Server 2005</title>
		<link>http://balajiramesh.wordpress.com/2008/03/10/convert-column-data-from-binary-to-string-with-sql-server-2005/</link>
		<comments>http://balajiramesh.wordpress.com/2008/03/10/convert-column-data-from-binary-to-string-with-sql-server-2005/#comments</comments>
		<pubDate>Mon, 10 Mar 2008 08:16:57 +0000</pubDate>
		<dc:creator>Balaji Ramesh</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://balajiramesh.wordpress.com/2008/03/10/convert-column-data-from-binary-to-string-with-sql-server-2005/</guid>
		<description><![CDATA[I had this binary column in SQL Server 2005 which was storing the MD5 hashes of certain files. The requirement was to display these hashes in a ASP.NET web UI. So i set about the task of converting the same. Binary data as such cannot be displayed on the UI. It needs to be converted [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=44&subd=balajiramesh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I had this binary column in SQL Server 2005 which was storing the MD5 hashes of certain files. The requirement was to display these hashes in a ASP.NET web UI. So i set about the task of converting the same. Binary data as such cannot be displayed on the UI. It needs to be converted to String. So you could go ahead and read byte by byte and convert it into a string, concatenating it as you go along. To facilitate things, SQL Server comes built in with a function that could convert common data types to string. It is called:</p>
<blockquote><p><font color="#333333"><strong>sys.fn_sqlvarbasetostr</strong></font></p>
</blockquote>
<p>The above function will in turn call </p>
<blockquote><p><strong>sys.fn_varbintohexsubstring</strong></p>
</blockquote>
<p>in our case because we are trying to convert binary to string. To use the function in a select query just do so:</p>
<blockquote><p><strong>SELECT <font color="#333333">sys.fn_sqlvarbasetostr(MD5Hash) From HashTable</font></strong></p>
</blockquote>
<p>where MD5Hash is the binary column you would like to convert.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/balajiramesh.wordpress.com/44/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/balajiramesh.wordpress.com/44/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/balajiramesh.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/balajiramesh.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/balajiramesh.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/balajiramesh.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/balajiramesh.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/balajiramesh.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/balajiramesh.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/balajiramesh.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/balajiramesh.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/balajiramesh.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=44&subd=balajiramesh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://balajiramesh.wordpress.com/2008/03/10/convert-column-data-from-binary-to-string-with-sql-server-2005/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a8706fb30f1c3933f690857a5200006a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">balajiramesh</media:title>
		</media:content>
	</item>
		<item>
		<title>Join Multiple OPENXML queries</title>
		<link>http://balajiramesh.wordpress.com/2008/01/13/join-multiple-openxml-queries/</link>
		<comments>http://balajiramesh.wordpress.com/2008/01/13/join-multiple-openxml-queries/#comments</comments>
		<pubDate>Sun, 13 Jan 2008 07:05:09 +0000</pubDate>
		<dc:creator>Balaji Ramesh</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://balajiramesh.wordpress.com/2008/01/13/join-multiple-openxml-queries/</guid>
		<description><![CDATA[If you ever wanted to run multiple openxml queries and join them give this a go:
DECLARE @idoc intDECLARE @idoc1 intDECLARE @doc varchar(1000)DECLARE @doc1 varchar(1000)SET @doc =&#8217;&#60;ROOT&#62;&#60;Customer CustomerID=&#8221;1&#8243; ContactName=&#8221;Balaji Ramesh&#8221; /&#62;&#60;/ROOT&#62;&#8217;SET @doc1 =&#8217;&#60;ROOT&#62;&#60;Customer CustomerID=&#8221;1&#8243; ContactNumber=&#8221;1234567890&#8243; /&#62;&#60;/ROOT&#62;&#8217;&#8211;Create an internal representation of the XML document.EXEC sp_xml_preparedocument @idoc OUTPUT, @docEXEC sp_xml_preparedocument @idoc1 OUTPUT, @doc1&#8211; Execute a SELECT statement that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=41&subd=balajiramesh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>If you ever wanted to run multiple openxml queries and join them give this a go:
<p>DECLARE @idoc int<br />DECLARE @idoc1 int<br />DECLARE @doc varchar(1000)<br />DECLARE @doc1 varchar(1000)<br />SET @doc =&#8217;&lt;ROOT&gt;&lt;Customer CustomerID=&#8221;1&#8243; ContactName=&#8221;Balaji Ramesh&#8221; /&gt;&lt;/ROOT&gt;&#8217;<br />SET @doc1 =&#8217;&lt;ROOT&gt;&lt;Customer CustomerID=&#8221;1&#8243; ContactNumber=&#8221;1234567890&#8243; /&gt;&lt;/ROOT&gt;&#8217;<br />&#8211;Create an internal representation of the XML document.<br />EXEC sp_xml_preparedocument @idoc OUTPUT, @doc<br />EXEC sp_xml_preparedocument @idoc1 OUTPUT, @doc1<br />&#8211; Execute a SELECT statement that uses the OPENXML rowset provider.
<p>SELECT d1.*, d2.ContactNumber<br />FROM&nbsp; OPENXML (@idoc, &#8216;/ROOT/Customer&#8217;,1)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WITH (CustomerID&nbsp; varchar(10),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ContactName varchar(20)) as d1<br />INNER JOIN <br />OPENXML (@idoc1, &#8216;/ROOT/Customer&#8217;,1)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WITH (CustomerID&nbsp; varchar(10),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ContactNumber varchar(20)) as d2<br />ON d1.CustomerID = d2.CustomerID
<p>EXEC sp_xml_removedocument @idoc<br />EXEC sp_xml_removedocument @idoc1
<p>This is a simple example but you get the idea.</p>
<p>
<div class="wlWriterSmartContent" style="display:inline;margin:0;padding:0;">Technorati Tags: <a href="http://technorati.com/tags/OPENXML" rel="tag">OPENXML</a>,<a href="http://technorati.com/tags/JOIN" rel="tag">JOIN</a>,<a href="http://technorati.com/tags/SQL%20Server" rel="tag">SQL Server</a></div></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/balajiramesh.wordpress.com/41/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/balajiramesh.wordpress.com/41/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/balajiramesh.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/balajiramesh.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/balajiramesh.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/balajiramesh.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/balajiramesh.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/balajiramesh.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/balajiramesh.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/balajiramesh.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/balajiramesh.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/balajiramesh.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=41&subd=balajiramesh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://balajiramesh.wordpress.com/2008/01/13/join-multiple-openxml-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a8706fb30f1c3933f690857a5200006a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">balajiramesh</media:title>
		</media:content>
	</item>
		<item>
		<title>View contents of a Stored Procedure (quickly)</title>
		<link>http://balajiramesh.wordpress.com/2008/01/11/view-contents-of-a-stored-procedure-quickly/</link>
		<comments>http://balajiramesh.wordpress.com/2008/01/11/view-contents-of-a-stored-procedure-quickly/#comments</comments>
		<pubDate>Fri, 11 Jan 2008 08:15:05 +0000</pubDate>
		<dc:creator>Balaji Ramesh</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Shortcuts]]></category>

		<guid isPermaLink="false">http://balajiramesh.wordpress.com/2008/01/11/view-contents-of-a-stored-procedure-quickly/</guid>
		<description><![CDATA[I am currently working on a SQL Server 2005 database that has over 500 stored procedures on it. And finding them on the object explorer has been tedious if i just need to view its contents. So i prefer typing in &#8216;SP_HELPTEXT &#60;procname&#62;&#8217; to view the contents of the procedure. But SQL Server management studio [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=40&subd=balajiramesh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I am currently working on a SQL Server 2005 database that has over 500 stored procedures on it. And finding them on the object explorer has been tedious if i just need to view its contents. So i prefer typing in &#8216;SP_HELPTEXT &lt;procname&gt;&#8217; to view the contents of the procedure. But SQL Server management studio provides an easier way to accomplish this.. You can assign a quick kepboard shortcut to access the contents of the procedure. Just go to Tools -&gt; Options -&gt; Keyboard and type in SP_HELPTEXT for a key of your choice. Now just select the procedure name and hit the shortcut key ..</p>
<p><a href="http://balajiramesh.files.wordpress.com/2008/01/image.png" target="_blank"><img height="140" alt="image" src="http://balajiramesh.files.wordpress.com/2008/01/image-thumb.png?w=240&#038;h=140" width="240"></a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/balajiramesh.wordpress.com/40/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/balajiramesh.wordpress.com/40/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/balajiramesh.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/balajiramesh.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/balajiramesh.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/balajiramesh.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/balajiramesh.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/balajiramesh.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/balajiramesh.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/balajiramesh.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/balajiramesh.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/balajiramesh.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=40&subd=balajiramesh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://balajiramesh.wordpress.com/2008/01/11/view-contents-of-a-stored-procedure-quickly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a8706fb30f1c3933f690857a5200006a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">balajiramesh</media:title>
		</media:content>

		<media:content url="http://balajiramesh.files.wordpress.com/2008/01/image-thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>System functions in SQL Server 2005</title>
		<link>http://balajiramesh.wordpress.com/2007/08/07/system-functions-in-sql-server-2005/</link>
		<comments>http://balajiramesh.wordpress.com/2007/08/07/system-functions-in-sql-server-2005/#comments</comments>
		<pubDate>Tue, 07 Aug 2007 04:31:01 +0000</pubDate>
		<dc:creator>Balaji Ramesh</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://balajiramesh.wordpress.com/2007/08/07/system-functions-in-sql-server-2005/</guid>
		<description><![CDATA[ Want to know what functions are available in your database but don&#8217;t want to go through the pain of searching help.. well you can actually look for it right in SQL Server management studio. Connect to your database. Expand programmability -&#62; Functions -&#62; System Functions. This lists out all the available system functions. A [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=18&subd=balajiramesh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://balajiramesh.files.wordpress.com/2007/08/dbfunctions.png"><img style="border-right:0;border-top:0;border-left:0;border-bottom:0;margin:0;" height="181" alt="dbfunctions" src="http://balajiramesh.files.wordpress.com/2007/08/dbfunctions-thumb.png?w=240&#038;h=181" width="240" align="left" border="0"></a> Want to know what functions are available in your database but don&#8217;t want to go through the pain of searching help.. well you can actually look for it right in SQL Server management studio. Connect to your database. Expand programmability -&gt; Functions -&gt; System Functions. This lists out all the available system functions. A pretty descriptive tooltip is also available. </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/balajiramesh.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/balajiramesh.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/balajiramesh.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/balajiramesh.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/balajiramesh.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/balajiramesh.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/balajiramesh.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/balajiramesh.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/balajiramesh.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/balajiramesh.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/balajiramesh.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/balajiramesh.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=18&subd=balajiramesh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://balajiramesh.wordpress.com/2007/08/07/system-functions-in-sql-server-2005/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a8706fb30f1c3933f690857a5200006a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">balajiramesh</media:title>
		</media:content>

		<media:content url="http://balajiramesh.files.wordpress.com/2007/08/dbfunctions-thumb.png" medium="image">
			<media:title type="html">dbfunctions</media:title>
		</media:content>
	</item>
		<item>
		<title>Updating Identity Columns in SQL Server</title>
		<link>http://balajiramesh.wordpress.com/2007/07/29/updating-identity-columns-in-sql-server/</link>
		<comments>http://balajiramesh.wordpress.com/2007/07/29/updating-identity-columns-in-sql-server/#comments</comments>
		<pubDate>Sun, 29 Jul 2007 06:18:43 +0000</pubDate>
		<dc:creator>Balaji Ramesh</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://balajiramesh.wordpress.com/2007/07/29/updating-identity-columns-in-sql-server/</guid>
		<description><![CDATA[Identity columns are kind of a helpful feature. But there might be times when you would want to change the value of an identity column.Guess what, SQL server does not allow it. I have not come across a way by which you can update the identity column but there sure is a way to insert [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=15&subd=balajiramesh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Identity columns are kind of a helpful feature. But there might be times when you would want to change the value of an identity column.Guess what, SQL server does not allow it. I have not come across a way by which you can update the identity column but there sure is a way to insert one. </p>
<p><font size="2"><font color="#0000ff">SET Identity_Insert</font> &lt;TableName&gt; ON</font></p>
<p>Now you will be able to insert a value into the identity column. Once done just revert the above statement to what follows to avoid unnecessary inserts:</p>
<p><font face="Consolas"><font color="#0000ff"><span class="kwrd">SET</span> <span class="kwrd">Identity_Insert <font color="#000000">&lt;TableName&gt; OFF</font></span></font></font></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/balajiramesh.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/balajiramesh.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/balajiramesh.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/balajiramesh.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/balajiramesh.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/balajiramesh.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/balajiramesh.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/balajiramesh.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/balajiramesh.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/balajiramesh.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/balajiramesh.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/balajiramesh.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=balajiramesh.wordpress.com&blog=1193083&post=15&subd=balajiramesh&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://balajiramesh.wordpress.com/2007/07/29/updating-identity-columns-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a8706fb30f1c3933f690857a5200006a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">balajiramesh</media:title>
		</media:content>
	</item>
	</channel>
</rss>