<?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>SQLcommitted</title>
	<atom:link href="http://sqlcommitted.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://sqlcommitted.com</link>
	<description>Committed with SQL</description>
	<lastBuildDate>Wed, 17 Apr 2013 10:26:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='sqlcommitted.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/3f856ffaa9e5feb7c22d6fbe4b7b7833?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>SQLcommitted</title>
		<link>http://sqlcommitted.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://sqlcommitted.com/osd.xml" title="SQLcommitted" />
	<atom:link rel='hub' href='http://sqlcommitted.com/?pushpress=hub'/>
		<item>
		<title>SQL Server&#8211; How to Encrypt Column Data</title>
		<link>http://sqlcommitted.com/2013/03/10/sql-server-how-to-encrypt-column-data/</link>
		<comments>http://sqlcommitted.com/2013/03/10/sql-server-how-to-encrypt-column-data/#comments</comments>
		<pubDate>Sun, 10 Mar 2013 19:15:00 +0000</pubDate>
		<dc:creator>SQLcommitted</dc:creator>
				<category><![CDATA[Encryption]]></category>
		<category><![CDATA[ALGORITHM]]></category>
		<category><![CDATA[CONVERT]]></category>
		<category><![CDATA[DecryptByKey]]></category>
		<category><![CDATA[DECRYPTION]]></category>
		<category><![CDATA[Encrypt]]></category>
		<category><![CDATA[EncryptByKey]]></category>
		<category><![CDATA[HashBytes]]></category>
		<category><![CDATA[Key_GUID]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLcommitted]]></category>
		<category><![CDATA[SYMMETRIC]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">https://sqlcommitted.wordpress.com/?p=364</guid>
		<description><![CDATA[Encryption is one of the most secure way to protect your confidential data like Social Security Number, Date Of Birth , Patient clinical information etc. We need to encrypt certain data to meet the business requirements and sometime to meet certain compliance. Here we’ll see how can we encrypt column data using symmetric key encryption [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=364&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Encryption is one of the most secure way to protect your confidential data like Social Security Number, Date Of Birth , Patient clinical information etc. We need to encrypt certain data to meet the business requirements and sometime to meet certain compliance. Here we’ll see how can we encrypt column data using symmetric key encryption in SQL Server 2012.</p>
<blockquote><p><a href="http://sqlcommitted.files.wordpress.com/2013/03/data-encryption.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;float:right;padding-top:0;border-width:0;" title="data-encryption" border="0" alt="data-encryption" align="right" src="http://sqlcommitted.files.wordpress.com/2013/03/data-encryption_thumb.jpg?w=301&#038;h=274" width="301" height="274" /></a></p>
</blockquote>
<p><u><strong>DEMO</strong></u></p>
<p>Lets first create a table and insert a record into it. Here in this demo we’ll encrypt the RegdNumber column data. </p>
<div class="mycode"></div>
<div class="mycode"></div>
<div class="mycode"></div>
<p class="mycode"><font color="#0000ff">CREATE TABLE</font>&#160; Employee (EmpID <font color="#0000ff">int</font>, EmpName <font color="#0000ff">varchar</font>(100), RegdNumber <font color="#0000ff">nvarchar</font>(20), EncryptedRegdNumber <font color="#0000ff">varbinary</font>(128))     <br /><font color="#0000ff">GO</font></p>
<p class="mycode"><font color="#0000ff">INSERT</font>&#160; Employee (EmpID, EmpName, RegdNumber)     <br /><font color="#0000ff">Values</font> (1,<font color="#ff0000">&#8216;Jackson&#8217;</font>,<font color="#ff0000">N&#8217;Regd_AA1&#8242;</font>)</p>
<p class="mycode"><strong></strong>&#160;</p>
<p class="mycode"><strong></strong>&#160;</p>
<p class="mycode"><strong></strong>&#160;</p>
<p class="mycode"><strong>Steps to encrypt </strong><strong>column data</strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p>
<p class="mycode"><font color="#000000"><strong>Step 1</strong>- Check if master key does not exist then create one</font></p>
<p> <font color="#000000">
<p class="mycode">&#160;</p>
<p>   <font color="#0000ff">IF</font> NOT EXISTS     <br />&#160;&#160;&#160; (<font color="#0000ff">SELECT</font> * <font color="#0000ff">FROM</font> sys.symmetric_keys <font color="#0000ff">WHERE</font> symmetric_key_id = 101)     <br />&#160;&#160;&#160; <font color="#0000ff">CREATE MASTER KEY ENCRYPTION BY      <br /></font>&#160;&#160;&#160; <font color="#0000ff">PASSWORD</font> = <font color="#ff0000">&#8216;abc12$$^7&#8242;</font>     <br /><font color="#0000ff">GO</font>     <br /></font>
<p class="mycode">
<table border="1" cellspacing="0" cellpadding="2" width="967">
<tbody>
<tr>
<td valign="top" width="965"><strong>Note : You should back up the master key by using <a href="http://msdn.microsoft.com/en-us/library/ms174387.aspx" target="_blank">BACKUP MASTER KEY</a> and store the backup in a secure, off-site location.</strong></td>
</tr>
</tbody>
</table>
<p><strong>Step 2</strong> &#8211; Create certificate </p>
<p class="mycode"><font color="#0000ff">CREATE CERTIFICATE</font> EmployeeCert     <br />&#160;&#160; <font color="#0000ff">WITH SUBJECT</font> = <font color="#ff0000">&#8216;Employee RegdNumber&#8217;</font>;     <br /><font color="#0000ff">GO</font></p>
<p class="mycode"><strong>Step 3</strong> &#8211; Create symmetric key using the certificate</p>
<p class="mycode"><font color="#0000ff">CREATE SYMMETRIC KEY</font> EmployeeRegdNumberKey_1     <br />&#160;&#160;&#160; <font color="#0000ff">WITH ALGORITHM</font> = <font color="#0000ff">AES_256</font>     <br />&#160;&#160;&#160; <font color="#0000ff">ENCRYPTION BY CERTIFICATE</font> EmployeeCert;     <br /><font color="#0000ff">GO</font></p>
<p class="mycode"><strong>Step 4</strong> &#8211; Open the symmetric key using&#160; which the data will be encrypted.</p>
<p class="mycode"><font color="#0000ff">OPEN SYMMETRIC KEY</font> EmployeeRegdNumber     <br />&#160;&#160; <font color="#0000ff">DECRYPTION BY CERTIFICATE</font> EmployeeCert;</p>
<p class="mycode"><strong>Step 5</strong> &#8211; Encrypt the value in column RegdNumber using the symmetric key EmployeeRegdNumberKey_1.     </p>
<p><font color="#ff00ff">UPDATE</font> Employee     <br /><font color="#0000ff">SET</font> EncryptedRegdNumber = <font color="#ff00ff">EncryptByKey</font>(<font color="#ff00ff">Key_GUID</font>(&#8216;EmployeeRegdNumber&#8217;)     <br />&#160;&#160;&#160; ,RegdNumber , 1, <font color="#ff00ff">HashBytes</font>(<font color="#ff0000">&#8216;SHA1&#8242;</font>, <font color="#ff00ff">CONVERT</font>( <font color="#0000ff">varbinary</font> , EmpID)));     <br /><font color="#0000ff">GO</font></p>
<p class="mycode">&#160;</p>
<p class="mycode">Now query the original RegdNumber, encrypted RegdNumber and decrypted RegdNumber.&#160; If encryption is working fine the the original RegdNumber column value should match with DecryptedRegdNumbers</p>
<p class="mycode"><font color="#0000ff">SELECT</font> RegdNumber ,EncryptedRegdNumber&#160;&#160;&#160; <font color="#0000ff">AS</font> <font color="#ff0000">&#8216;Encrypted RegdNumber&#8217;</font>, </p>
<p class="mycode"><font color="#ff00ff">CONVERT</font>(<font color="#0000ff">nvarchar</font>,&#160;&#160; <font color="#ff00ff">DecryptByKey</font>(EncryptedRegdnumbet, 1 ,<font color="#ff00ff">HashBytes</font>(<font color="#ff0000">&#8216;SHA1&#8242;</font>, <font color="#ff00ff">CONVERT</font>(<font color="#0000ff">varbinary</font>, empid))))&#160; <font color="#0000ff">AS</font><font color="#ff0000"> &#8216;Decrypted RegdNumber&#8217;</font> </p>
<p class="mycode"><font color="#0000ff">FROM</font> Employee;     <br /><font color="#0000ff">GO</font></p>
<p>The above script you can use in your local environment to check how you can encrypt column data. </p>
<p>Hope the above demo will help to understand how to encrypt column data. </p>
<p>&#160;</p>
<p>If you liked this post, do like on Facebook at <a href="https://www.facebook.com/s4sql">https://www.facebook.com/s4sql</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcommitted.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcommitted.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcommitted.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcommitted.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlcommitted.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlcommitted.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlcommitted.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlcommitted.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcommitted.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcommitted.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcommitted.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcommitted.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcommitted.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcommitted.wordpress.com/364/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=364&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlcommitted.com/2013/03/10/sql-server-how-to-encrypt-column-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/b10b983f383d1fe206d0acbac61cb3c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">s4sql</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2013/03/data-encryption_thumb.jpg" medium="image">
			<media:title type="html">data-encryption</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server &#8211; Index Selection Fundamental</title>
		<link>http://sqlcommitted.com/2013/01/17/sql-server-index-selection-fundamental/</link>
		<comments>http://sqlcommitted.com/2013/01/17/sql-server-index-selection-fundamental/#comments</comments>
		<pubDate>Thu, 17 Jan 2013 03:32:29 +0000</pubDate>
		<dc:creator>SQLcommitted</dc:creator>
				<category><![CDATA[Index]]></category>
		<category><![CDATA[Transact-SQL]]></category>
		<category><![CDATA[Index Scan]]></category>
		<category><![CDATA[Index Seek]]></category>
		<category><![CDATA[Index Selection]]></category>
		<category><![CDATA[SARGgable]]></category>
		<category><![CDATA[SQL Index]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">https://sqlcommitted.wordpress.com/?p=359</guid>
		<description><![CDATA[Index is one of most widely discussed topic among developers and DBAs. During query optimization Index is one of the important aspects. I came across multiple instances where Developer/ DBA creates Index but they are not sure whether that index is used by the optimizer or not. Also I received emails from developer asking How [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=359&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Index is one of most widely discussed topic among developers and DBAs. During query optimization Index is one of the important aspects. I came across multiple instances where Developer/ DBA creates Index but they are not sure whether that index is used by the optimizer or not. Also I received emails from developer asking How to design an Index? So Here I’ll try to explain the fundamental of Index Selection.</p>
<p>While designing an Index the basic idea is that the optimizer should use the index so that it will fetch the data using an optimal path with fewer disks I/O operation and less system resource usage. </p>
<p>Below are the important parameters for Optimizer to consider before it selects an Index to use</p>
<ul>
<li>Predicate from the WHERE clause</li>
<li>Join Condition </li>
<li>Other limiting option used in a query (Ex: Group by, Distinct etc.) </li>
</ul>
<p>Using Index, optimizer can perform either <strong>Seek Operation</strong> or <strong>Scan Operation</strong>.</p>
<p>Seek Operation is used when fetching a single value or a range of value and in Scan operation it traverse through the Index pages either forward or backward.</p>
<p>All predicate used in where clause are not always used for Index selection. Predicate which can be converted into an Index operation are often called <strong>SARGgable</strong> or <strong>Search-ARGument-able</strong> and predicate that do not match the selected index are called non-sargable predicates which are used as filter predicate. SQL SERVER usually evaluated non-sargable predicates with in the seek/scan operator in the query tree.</p>
<p>Once you create an Index always checks with your query to determine whether it improves your query performance. If it is not improving your query performance then remove that index. </p>
<p>To understand SARGgable and Non SARGgable predicate,&#160; let me demonstrate it using a simple demo.</p>
<p>For this Demo I’m using AdventureWorks database which can be downloadable from <a href="http://msftdbprodsamples.codeplex.com/releases/view/93587" target="_blank">here</a>.</p>
<p>Step 1: create table Product_1 using Product table.</p>
<p><font color="#0000ff">SELECT</font> * <font color="#0000ff">INTO</font> Product_1 <font color="#0000ff">FROM</font> [Production].[Product]</p>
<p>Step 2: Create an UNIQUE Clustered Index on Product_1 for Column ProductID</p>
<p><font color="#0000ff">CREATE UNIQUE CLUSTERED INDEX</font> CIX_Product <font color="#0000ff">ON</font> Product_1 (ProductID)</p>
<p>Step 3: Run the below query and check its actual execution plan. You can enable actual execution plan either by shortcut Ctrl+M or from the Query menu in SSMS.</p>
<p><font color="#0000ff">SELECT</font> * <font color="#0000ff">FROM</font> Product_1 <font color="#0000ff">WHERE</font> ProductID &lt;100 and Makeflag=1</p>
<p>We can see below Optimizer uses the Index Seek operation to fetch the data. If you mouse over on Clustered Index Seek operator you will get the operator details. Here we can see that ProductID is used for Seek predicate as we have Index on that and column MakeFlag is used for filter predicate.</p>
<p><b>Actual Execution Plan:</b></p>
<p><a href="http://sqlcommitted.files.wordpress.com/2013/01/image5.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2013/01/image_thumb5.png?w=741&#038;h=568" width="741" height="568" /></a></p>
<p>If you liked this post, do like on Facebook at <a href="https://www.facebook.com/s4sql">https://www.facebook.com/s4sql</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcommitted.wordpress.com/359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcommitted.wordpress.com/359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcommitted.wordpress.com/359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcommitted.wordpress.com/359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlcommitted.wordpress.com/359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlcommitted.wordpress.com/359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlcommitted.wordpress.com/359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlcommitted.wordpress.com/359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcommitted.wordpress.com/359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcommitted.wordpress.com/359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcommitted.wordpress.com/359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcommitted.wordpress.com/359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcommitted.wordpress.com/359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcommitted.wordpress.com/359/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=359&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlcommitted.com/2013/01/17/sql-server-index-selection-fundamental/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/b10b983f383d1fe206d0acbac61cb3c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">s4sql</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2013/01/image_thumb5.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server &#8211; New Analytical functions in SQL Server 2012 &#8211; Lead and Lag</title>
		<link>http://sqlcommitted.com/2013/01/11/sql-server-new-analytical-functions-in-sql-server-2012-lead-and-lag/</link>
		<comments>http://sqlcommitted.com/2013/01/11/sql-server-new-analytical-functions-in-sql-server-2012-lead-and-lag/#comments</comments>
		<pubDate>Fri, 11 Jan 2013 03:50:00 +0000</pubDate>
		<dc:creator>SQLcommitted</dc:creator>
				<category><![CDATA[SQL SERVER 2012]]></category>
		<category><![CDATA[Transact-SQL]]></category>
		<category><![CDATA[Lag]]></category>
		<category><![CDATA[Lead]]></category>
		<category><![CDATA[SQL Analytical Function]]></category>
		<category><![CDATA[SQL Function]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQLcommitted]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">https://sqlcommitted.wordpress.com/?p=355</guid>
		<description><![CDATA[LAG: Using this function we can fetch the nth row before (Lag) the Current row without using self-join. It is useful when we need to compare the current row values with values in a previous row. Syntax: LAG (scalar_expression [,offset] [,default]) &#160;&#160;&#160; OVER ( [ partition_by_clause ] order_by_clause ) EXAMPLE: Create an Employee table and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=355&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>LAG:
<p>Using this function we can fetch the nth row before (Lag) the Current row without using self-join.
<p>It is useful when we need to compare the current row values with values in a previous row.
<p>Syntax:
<p>LAG (scalar_expression [,offset] [,default])
<p>&nbsp;&nbsp;&nbsp; OVER ( [ partition_by_clause ] order_by_clause )
<p>EXAMPLE:
<p>Create an Employee table and insert some records to it.
<div id="codeSnippetWrapper">
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet"><span style="color:#0000ff;">CREATE</span> <span style="color:#0000ff;">TABLE</span>  Employee (EmpID <span style="color:#0000ff;">int</span>, HikeDate <span style="color:#0000ff;">date</span>, Salary money)<br /><span style="color:#0000ff;">GO</span><br />INSERT <span style="color:#0000ff;">INTO</span> employee <span style="color:#0000ff;">values</span> (1, <span style="color:#006080;">'2009-04-01 00:00:00.000'</span>,10000),<br />                            (1, <span style="color:#006080;">'2010-04-01 00:00:00.000'</span>,17000),<br />                            (1, <span style="color:#006080;">'2011-04-01 00:00:00.000'</span>,23000)<br /><span style="color:#0000ff;">GO</span><br /><br /><br /><span style="color:#0000ff;">SELECT</span> EmpID, HikeDate, Salary<br /><span style="color:#0000ff;">FROM</span> Employee<br /><span style="color:#0000ff;">ORDER</span> <span style="color:#0000ff;">BY</span>  HikeDate<br /></pre>
<p></div>
<p>Output:</p>
<p><a href="http://sqlcommitted.files.wordpress.com/2013/01/image.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2013/01/image_thumb.png?w=547&#038;h=164" width="547" height="164"></a></p>
<p>&nbsp;</p>
<p>Now my requirement is to show what the previous Salary before current hike was?</p>
<p><strong><font color="#c0504d">Solution Using <u>Lag function</u>:</font></strong></p>
<p><a href="http://sqlcommitted.files.wordpress.com/2013/01/image1.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2013/01/image_thumb1.png?w=716&#038;h=149" width="716" height="149"></a></p>
<p>&nbsp;</p>
<p><a href="http://sqlcommitted.files.wordpress.com/2013/01/image2.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2013/01/image_thumb2.png?w=716&#038;h=211" width="716" height="211"></a></p>
<p>LEAD:</p>
<p>Using this function we can fetch the nth row after (LEAD) the current row without using self-join.</p>
<p>It is useful when we need to compare the current row values with values in a following row.</p>
<p>Syntax:</p>
<blockquote>
<p>LEAD (scalar_expression [,offset] [,default]) </p>
<p>OVER ( [ partition_by_clause ] order_by_clause )</p>
</blockquote>
<pre></pre>
<p>Example:</p>
<p>My requirement is to show what my following year salary is?</p>
<p>&nbsp;
<p><strong><font color="#c0504d">Solution using <u>Lead function</u>:</font></strong></p>
<p><a href="http://sqlcommitted.files.wordpress.com/2013/01/image3.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2013/01/image_thumb3.png?w=738&#038;h=157" width="738" height="157"></a></p>
<p><a href="http://sqlcommitted.files.wordpress.com/2013/01/image4.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2013/01/image_thumb4.png?w=740&#038;h=269" width="740" height="269"></a></p>
<p>&nbsp;
<p><b>Note</b>: Default offset value is <strong>1</strong>. We can specify offset value by a column or a sub query, or other expression that evaluates to a positive integer. Negative value or analytical function can’t be used as offset value.</p>
<p>If you liked this post, do like on Facebook at <a href="https://www.facebook.com/s4sql">https://www.facebook.com/s4sql</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcommitted.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcommitted.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcommitted.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcommitted.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlcommitted.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlcommitted.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlcommitted.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlcommitted.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcommitted.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcommitted.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcommitted.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcommitted.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcommitted.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcommitted.wordpress.com/355/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=355&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlcommitted.com/2013/01/11/sql-server-new-analytical-functions-in-sql-server-2012-lead-and-lag/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/b10b983f383d1fe206d0acbac61cb3c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">s4sql</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2013/01/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2013/01/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2013/01/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2013/01/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2013/01/image_thumb4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server &#8211; Happy New Year 2013 and Happy First Anniversary to My Blog</title>
		<link>http://sqlcommitted.com/2013/01/01/sql-server-happy-new-year-2013-and-happy-first-anniversary-to-my-blog/</link>
		<comments>http://sqlcommitted.com/2013/01/01/sql-server-happy-new-year-2013-and-happy-first-anniversary-to-my-blog/#comments</comments>
		<pubDate>Tue, 01 Jan 2013 01:42:00 +0000</pubDate>
		<dc:creator>SQLcommitted</dc:creator>
				<category><![CDATA[NEWS]]></category>
		<category><![CDATA[SqlCommitted]]></category>
		<category><![CDATA[Aniversary]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLcommitted]]></category>

		<guid isPermaLink="false">https://sqlcommitted.wordpress.com/?p=343</guid>
		<description><![CDATA[Wish you a very Happy New Year 2013. Today is a special day for me to celebrate the New Year because today my blog post turned 1 year old. I can’t believe that I have been blogging for a year now. This blog was just created with an intension to share what I learned during [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=343&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Wish you a very <strong><font color="#f79646">Happy New Year 2013.</font></strong> Today is a special day for me to celebrate the New Year because today my blog post turned 1 year old. I can’t believe that I have been blogging for a year now. This blog was just created with an intension to share what I learned during my daily work. I’m happy that I initiated to contribute to the SQL Server community.</p>
<p>Thank you to Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">B</a>|<a href="https://twitter.com/sqlauthority" target="_blank">T</a>) and Vinod Kumar (<a href="http://www.extremeexperts.com/General/Home/Homepage.aspx" target="_blank">B</a>|<a href="https://twitter.com/vinodk_sql" target="_blank">T</a>) for their guidance and encouragement. Thank you to my Wife for her support. Last but not least I thank you to all my readers.</p>
<p>I posted 24 blog posts in 2012 that is one post in every 2 weeks. Many have their New Year resolutions and I’m not the exception in this case. One of my New Year resolutions is to write at least one blog post per week.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcommitted.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcommitted.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcommitted.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcommitted.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlcommitted.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlcommitted.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlcommitted.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlcommitted.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcommitted.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcommitted.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcommitted.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcommitted.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcommitted.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcommitted.wordpress.com/343/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=343&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlcommitted.com/2013/01/01/sql-server-happy-new-year-2013-and-happy-first-anniversary-to-my-blog/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/b10b983f383d1fe206d0acbac61cb3c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">s4sql</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server &#8211; Order of Column and Impact of equality operator on Index operation</title>
		<link>http://sqlcommitted.com/2012/12/24/sql-server-order-of-column-and-impact-of-equality-operator-on-index-operation/</link>
		<comments>http://sqlcommitted.com/2012/12/24/sql-server-order-of-column-and-impact-of-equality-operator-on-index-operation/#comments</comments>
		<pubDate>Mon, 24 Dec 2012 05:41:00 +0000</pubDate>
		<dc:creator>SQLcommitted</dc:creator>
				<category><![CDATA[Index]]></category>
		<category><![CDATA[Index Scan]]></category>
		<category><![CDATA[Index Seek]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Index]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQLcommitted]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">https://sqlcommitted.wordpress.com/?p=337</guid>
		<description><![CDATA[Does order of Column in where clause matters? Before you answer to this question I recommend all to read the blog post SQLAuthority. Whenever I have any doubt, I always play around with it to clarify my doubt. While doing experiment with index operation, I learnt something and here I’m demonstrating what I learnt? Let’s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=337&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Does order of Column in where clause matters?</p>
<p>Before you answer to this question I recommend all to read the blog post <a href="http://blog.sqlauthority.com/2010/08/25/sql-server-deos-order-of-column-in-where-clause-matter/" target="_blank">SQLAuthority</a>.</p>
<p>Whenever I have any doubt, I always play around with it to clarify my doubt. While doing experiment with index operation, I learnt something and here I’m demonstrating what I learnt? </p>
<p>Let’s do some experiment,</p>
<p>In below experiment I’m using the AdevntureWorks database, which can be downloadable from <a href="http://msftdbprodsamples.codeplex.com/releases/view/93587" target="_blank">Codeplex</a>.</p>
<p><b>Demo – 1 (Order doesn’t matter</b>)</p>
<p>Create Customer1 table from Sales.Customer table.</p>
<p><font color="#0000ff">SELECT</font> * <font color="#0000ff">INTO</font> Customer1 <font color="#0000ff">FROM</font> Sales.Customer</p>
<p>Now Create an Index on Column CustomerID,TerritoryID</p>
<p><font color="#0000ff">CREATE INDEX</font> IXNC_Customer1_1 <font color="#0000ff">ON</font> Customer1 (CustomerID,TerritoryID)</p>
<p>Run below two queries, the only difference in the queries are the order of column in where clause.</p>
<p><font color="#00c100">&#8211;Query &#8211; 1</font></p>
<p><font color="#0000ff">SELECT</font> CustomerID, TerritoryID</p>
<p><font color="#0000ff">FROM</font> Customer1</p>
<p><font color="#0000ff">WHERE</font> CustomerID =1 <font color="#666666">AND</font> TerritoryID =1</p>
<p><font color="#00c100">&#8211;Query &#8211; 2</font></p>
<p><font color="#0000ff">SELECT</font> CustomerID, TerritoryID </p>
<p><font color="#0000ff">FROM</font> Customer1 </p>
<p><font color="#0000ff">WHERE</font>&#160; TerritoryID =1 and CustomerID = 1</p>
<p>Compare Execution plan for both the queries:</p>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/12/image.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/12/image_thumb.png?w=757&#038;h=271" width="757" height="271" /></a></p>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/12/image1.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/12/image_thumb1.png?w=767&#038;h=665" width="767" height="665" /></a></p>
<p>&#160;</p>
<p>We can see in the above Demo (Fig-1) both queries uses Index Seek and query cost is same.</p>
<p>Now compare index seek operation for both of the queries, Seek predicates prefix CustomerID as the first column in both the cases and both CustomerID and TerritoryID used by SQL server as seek predicates.</p>
<p>Before proceed further, from Demo- 1 we can conclude that the order doesn’t matter in where clause. </p>
<p>&#160;</p>
<p><b>Demo – 2 (It matters if other than first column of the index used in where clause)</b></p>
<p>Now let’s see what will happen if we use only one column in where clause?</p>
<p>Run below two queries. Here I’ve used CustomerID in first query and TerritoryID in second query respectively in where clause.</p>
<p><font color="#00c100">&#8211;Query &#8211; 3</font></p>
<p><font color="#0000ff">SELECT</font> CustomerID, TerritoryID </p>
<p><font color="#0000ff">FROM</font> Customer1 </p>
<p><font color="#0000ff">WHERE</font>&#160; CustomerID = 1</p>
<p><font color="#00c100">&#8211;Query &#8211; 4</font></p>
<p><font color="#0000ff">SELECT</font> CustomerID, TerritoryID </p>
<p><font color="#0000ff">FROM</font> Customer1 </p>
<p><font color="#0000ff">WHERE</font>&#160; TerritoryID = 1 </p>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/12/image2.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/12/image_thumb2.png?w=829&#038;h=240" width="829" height="240" /></a></p>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/12/image3.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/12/image_thumb3.png?w=694&#038;h=611" width="694" height="611" /></a></p>
<p>In <strong>Demo &#8211; 2</strong>, We can see that when we use Column CustomerID in Where clause it uses Seek Predicate for CustomerID Column but in Query – 4, there is no seek predicate because it is using Index scan.</p>
<p>In Fig – 4, The actual query plan shows the actual number of row are more in Query – 4, so we may assume that in second query, the number of resultant rows are more so it uses Index Scan and It doesn’t matter whether we use first column or second column of the index in where clause. It does matter if we use only one column of the index.</p>
<p>To prove that, now let’s see if we have only one row for TerritoryID is equal to 1, which operation will be used by SQL Server.</p>
<p>Below query will delete all records from Customer1 table except one row where TerritoryID = 1.</p>
<p><font color="#0000ff">DELETE FROM</font> Customer1 <font color="#0000ff">WHERE</font> CustomerID &gt;1 <font color="#666666">AND</font> TerritoryID = 1</p>
<p>Confirm it by running below query that we have only one record in Customer1 table where TerritoryID = 1</p>
<p><font color="#0000ff">SELECT</font> * <font color="#0000ff">FROM</font> Customer1 <font color="#0000ff">WHERE</font> TerritoryID = 1</p>
<p>Now let’s run the same query that is Query – 4</p>
<p><font color="#00c100">&#8211;Query &#8211; 5</font></p>
<p><font color="#0000ff">SELECT</font> CustomerID, TerritoryID </p>
<p><font color="#0000ff">FROM</font> Customer1 </p>
<p><font color="#0000ff">WHERE</font>&#160; TerritoryID = 1 </p>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/12/image4.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/12/image_thumb4.png?w=613&#038;h=194" width="613" height="194" /></a></p>
<p>In above example we can see that even though there is only one row for TerritoryID = 1, It is not using TerritoryID column as seek predicate.</p>
<p>It is using Index scan because TerritoryID is not the first column of the index.</p>
<p><b>Demo – 3</b>: <strong>The second column will participate in seek predicate Only If the first column of the index compares with equality operator irrespective of the order in where clause</strong>.</p>
<p>&#160;</p>
<p><b>Note</b>: As I’ve deleted some rows from the table. I’m dropping the table and recreating the Table and Index.</p>
<p><font color="#0000ff">DROP TABLE</font> Customer1</p>
<p><font color="#0000ff">SELECT</font> * <font color="#0000ff">INTO</font> Customer1 <font color="#0000ff">FROM</font> Sales.Customer</p>
<p><font color="#0000ff">CREATE INDEX</font> IXNC_Customer1_1 <font color="#0000ff">ON</font> Customer1 (CustomerID,TerritoryID)</p>
<p>GO</p>
<p>Let’s run below two queries, where in first query, CustomerID is compared with equality operator and second query, CustomerID is compared with non-equality operator.</p>
<p><font color="#00c100">&#8211;Query &#8211; 6</font></p>
<p><font color="#0000ff">SELECT</font> CustomerID, TerritoryID </p>
<p><font color="#0000ff">FROM</font> Customer1 </p>
<p><font color="#0000ff">WHERE</font>&#160; TerritoryID &gt;1 <font color="#666666">AND</font> CustomerID = 1</p>
<p><font color="#00c100">&#8211;Query &#8211; 7</font></p>
<p><font color="#0000ff">SELECT</font> CustomerID, TerritoryID </p>
<p><font color="#0000ff">FROM</font> Customer1 </p>
<p><font color="#0000ff">WHERE</font> TerritoryID &gt; 1 <font color="#666666">AND</font> CustomerID &gt; 1</p>
<p>&#160;</p>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/12/image5.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/12/image_thumb5.png?w=760&#038;h=312" width="760" height="312" /></a></p>
<p>&#160;</p>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/12/image6.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/12/image_thumb6.png?w=676&#038;h=573" width="676" height="573" /></a></p>
<p>In the above example, we can see that even though both the queries uses Index seek operation but in Query &#8211; 5, Both CustomerID and TerritoryID columns are participated in Seek Predicate and in Query &#8211; 6 only CustomerID is participated in Seek predicate and TerritoryID is used as filter predicate.</p>
<p>&#160;</p>
<p><b>Conclusion:</b></p>
<ul>
<li> Order of column in where clause doesn’t matter.</li>
<li> It matters if we use Columns except first column of the Index.</li>
<li> If first column of the index compared with equality operator then only second column will participate in Seek predicate. </li>
</ul>
<p>If you liked this post, do like on Facebook at <a href="https://www.facebook.com/s4sql">https://www.facebook.com/s4sql</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcommitted.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcommitted.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcommitted.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcommitted.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlcommitted.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlcommitted.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlcommitted.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlcommitted.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcommitted.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcommitted.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcommitted.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcommitted.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcommitted.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcommitted.wordpress.com/337/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=337&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlcommitted.com/2012/12/24/sql-server-order-of-column-and-impact-of-equality-operator-on-index-operation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/b10b983f383d1fe206d0acbac61cb3c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">s4sql</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/12/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/12/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/12/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/12/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/12/image_thumb4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/12/image_thumb5.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/12/image_thumb6.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL SERVER &#8211; Trace Flags</title>
		<link>http://sqlcommitted.com/2012/12/17/sql-server-trace-flags/</link>
		<comments>http://sqlcommitted.com/2012/12/17/sql-server-trace-flags/#comments</comments>
		<pubDate>Mon, 17 Dec 2012 02:30:00 +0000</pubDate>
		<dc:creator>SQLcommitted</dc:creator>
				<category><![CDATA[Transact-SQL]]></category>
		<category><![CDATA[DBCC]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLcommitted]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[Trace Flags]]></category>

		<guid isPermaLink="false">https://sqlcommitted.wordpress.com/?p=319</guid>
		<description><![CDATA[To know about a topic we usually ask questions. Here I used the same method to explain about trace flag of SQL Server. Below are some questions related to trace flags. What is the use of Trace Flag? Trace Flags are used to enable or disable certain functionality of SQL server temporarily. It is used [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=319&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>To know about a topic we usually ask questions. Here I used the same method to explain about trace flag of SQL Server.</p>
<p>Below are some questions related to trace flags.</p>
<p><b>What is the use of Trace Flag?</b></p>
<p>Trace Flags are used to enable or disable certain functionality of SQL server temporarily. It is used to diagnose performance issues or to debug stored procedures.</p>
<p><strong>Where will I get all the trace flags available for SQL Server?</strong>&#160;</p>
<p>For SQL Server 2012 : &#8211; <a title="http://msdn.microsoft.com/en-us/library/ms188396.aspx" href="http://msdn.microsoft.com/en-us/library/ms188396.aspx">http://msdn.microsoft.com/en-us/library/ms188396.aspx</a></p>
<p>For SQL Server 2008 R2 : &#8211; <a title="http://msdn.microsoft.com/en-us/library/ms188396(v=sql.105).aspx" href="http://msdn.microsoft.com/en-us/library/ms188396(v=sql.105).aspx">http://msdn.microsoft.com/en-us/library/ms188396(v=sql.105).aspx</a></p>
<p>For SQL Server 2008 : &#8211; <a title="http://msdn.microsoft.com/en-us/library/ms188396(v=sql.100).aspx" href="http://msdn.microsoft.com/en-us/library/ms188396(v=sql.100).aspx">http://msdn.microsoft.com/en-us/library/ms188396(v=sql.100).aspx</a></p>
<p>For SQL Server 2005 : &#8211; <a title="http://msdn.microsoft.com/en-us/library/ms188396(v=sql.90).aspx" href="http://msdn.microsoft.com/en-us/library/ms188396(v=sql.90).aspx">http://msdn.microsoft.com/en-us/library/ms188396(v=sql.90).aspx</a></p>
<p><b>What are the types of Trace Flags?</b></p>
<p>SQL Server provides below two types of trace flag. </p>
<p><b>Session Level</b>: Active and visible only to a specific connection where it is set. A session level trace flag never effect any other session. </p>
<p><b>Global Level</b>: Active and visible at the server level (for all connections). Some trace flag can only be set at global level. If a global trace flag enable at session level there will be no effect of the flag on the server. </p>
<p><b>Note</b>: Some of the trace flags can be enabled either at session level or at global level.</p>
<p><b>How to enable or disable a Trace Flag?</b></p>
<p>Using method <font color="#0000ff">DBCC</font> TRACEON, we can enable a trace flag. </p>
<p><b>Ex:</b> <font color="#0000ff">DBCC</font> TRACEON (1224)</p>
<p>To set a trace flag at Global level use argument -1.</p>
<p><b>Ex:</b> <font color="#0000ff">DBCC</font> TRACEON (1224, -1)</p>
<p>Global level trace flag can also be set using –T start-up option. Using –T start up option we can’t enable any session level trace flag.</p>
<p><b>How to check a trace flag is enabled or disabled?</b></p>
<p>Using method DBCC TRACESTATUS, we can check the status of a trace flag.</p>
<p><b>Ex:</b> <font color="#0000ff">DBCC</font> TRACESTATUS (-1) will display list of trace flags enabled at global level</p>
<p><font color="#0000ff">DBCC</font> TRACESTATUS () will display list of trace flags enabled for current session </p>
<p>&#160;</p>
<p>If you liked this post, do like on Facebook at <a href="https://www.facebook.com/s4sql">https://www.facebook.com/s4sql</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcommitted.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcommitted.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcommitted.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcommitted.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlcommitted.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlcommitted.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlcommitted.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlcommitted.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcommitted.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcommitted.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcommitted.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcommitted.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcommitted.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcommitted.wordpress.com/319/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=319&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlcommitted.com/2012/12/17/sql-server-trace-flags/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/b10b983f383d1fe206d0acbac61cb3c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">s4sql</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server &#8211; Customize Database object Script</title>
		<link>http://sqlcommitted.com/2012/11/22/sql-server-customize-database-object-script/</link>
		<comments>http://sqlcommitted.com/2012/11/22/sql-server-customize-database-object-script/#comments</comments>
		<pubDate>Thu, 22 Nov 2012 01:30:00 +0000</pubDate>
		<dc:creator>SQLcommitted</dc:creator>
				<category><![CDATA[SSMS Environment Settings]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQLcommitted]]></category>
		<category><![CDATA[SSMS]]></category>

		<guid isPermaLink="false">https://sqlcommitted.wordpress.com/?p=316</guid>
		<description><![CDATA[SSMS provides functionality to generate script for database objects. I’ve seen developer use this functionality to generate script for various objects like Tables, Procedures, Triggers and other database objects but after generating the script they manually modify the generated scripts. When I asked one of the developers why you need to modify the generated scripts? [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=316&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>SSMS provides functionality to generate script for database objects. I’ve seen developer use this functionality to generate script for various objects like Tables, Procedures, Triggers and other database objects but after generating the script they manually modify the generated scripts. When I asked one of the developers why you need to modify the generated scripts? He said the generated script is not meeting his requirement.</p>
<p>Below are some of the requirements &#8211; </p>
<ul>
<li>Script should not start with USE &lt;database name&gt;.</li>
<li>It should check for existence of the object prior to the create statement.</li>
<li>It should include collation </li>
<li>If the object is Table or view it should generate scripts for all the associated index and Triggers.</li>
</ul>
<p>SSMS allow to customize our script as per our requirement. SSMS has options to customize it.</p>
<p>Follow below steps to customize your scripts.</p>
<p><strong>Step 1</strong> &#8211; Go to Tools – Option. It will open the Option Page</p>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/11/image.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/11/image_thumb.png?w=642&#038;h=460" width="642" height="460" /></a></p>
<p><strong>Step 2</strong> &#8211; Click on SQL Server Object Explorer and select Scripting</p>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/11/image1.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/11/image_thumb1.png?w=653&#038;h=461" width="653" height="461" /></a></p>
<p><strong>Step 3</strong> &#8211; On left side panel you can find various customization option grouped into below three categories.</p>
<ul>
<li><b>General scripting options</b></li>
<li><b>Object scripting options</b></li>
<li><b>Table and view options</b></li>
</ul>
<p>You can set these options as per your requirement.</p>
<p><strong>Example:</strong> If you don’t want Use &lt;Database name&gt; statement at the beginning of your script then Set Script USE &lt;database&gt; to false.</p>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/11/image2.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/11/image_thumb2.png?w=662&#038;h=486" width="662" height="486" /></a></p>
<p>If you liked this post, do like on Facebook at <a href="https://www.facebook.com/s4sql">https://www.facebook.com/s4sql</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcommitted.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcommitted.wordpress.com/316/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcommitted.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcommitted.wordpress.com/316/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlcommitted.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlcommitted.wordpress.com/316/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlcommitted.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlcommitted.wordpress.com/316/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcommitted.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcommitted.wordpress.com/316/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcommitted.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcommitted.wordpress.com/316/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcommitted.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcommitted.wordpress.com/316/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=316&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlcommitted.com/2012/11/22/sql-server-customize-database-object-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/b10b983f383d1fe206d0acbac61cb3c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">s4sql</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/11/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/11/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/11/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server&#8211; Unique Constraint VS Unique Index</title>
		<link>http://sqlcommitted.com/2012/08/28/sql-server-unique-constraint-vs-unique-index/</link>
		<comments>http://sqlcommitted.com/2012/08/28/sql-server-unique-constraint-vs-unique-index/#comments</comments>
		<pubDate>Tue, 28 Aug 2012 06:33:00 +0000</pubDate>
		<dc:creator>SQLcommitted</dc:creator>
				<category><![CDATA[SQL Objects]]></category>
		<category><![CDATA[SqlCommitted]]></category>
		<category><![CDATA[Transact-SQL]]></category>
		<category><![CDATA[Filtered Index]]></category>
		<category><![CDATA[SQLcommitted]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[Unique Constraint]]></category>
		<category><![CDATA[Unique Index]]></category>

		<guid isPermaLink="false">https://sqlcommitted.wordpress.com/?p=306</guid>
		<description><![CDATA[Both Unique constraint and Unique Index enforces uniqueness of the column. When we define an Unique constraint, SQL server creates an Unique non clustered index on the column where Unique constraint is defined. Even though both of them can be used for same purpose but consider below points before you decide which one to use. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=306&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Both Unique constraint and Unique Index enforces uniqueness of the column. When we define an Unique constraint, SQL server creates an Unique non clustered index on the column where Unique constraint is defined. </p>
<p>Even though both of them can be used for same purpose but consider below points before you decide which one to use.</p>
<p><strong>1 </strong>-&#160; From SQL server 2008 onwards we have Filtered index , Include columns which can’t be define on index which is created while defining Unique constraint but we can define it while defining Unique Index. We can have better control over the Unique index.</p>
<p><strong>2</strong> -&#160; Derived from point 1, sometime we need our column should be unique but it should allow multiple NULL values in that case by implementing Unique filtered Index we can achieve it. Also we can avoid Key lookup by adding included columns in an Unique Index but not in Unique constraint.</p>
<p><strong>3 </strong>-&#160; Unique constraint always creates non clustered index. Unique Index can be defined either Clustered or non Clustered.</p>
<p><strong>4</strong> -&#160; You can’t drop only the index associated with the Unique constraint. </p>
<p>Leave your comment, If you have any points which we should consider before we decide which one to use between Unique Constraint and Unique Index.</p>
<p>&#160;</p>
<p>If you liked this post, do like on Facebook at <a href="https://www.facebook.com/s4sql">https://www.facebook.com/s4sql</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcommitted.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcommitted.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcommitted.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcommitted.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlcommitted.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlcommitted.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlcommitted.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlcommitted.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcommitted.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcommitted.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcommitted.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcommitted.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcommitted.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcommitted.wordpress.com/306/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=306&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlcommitted.com/2012/08/28/sql-server-unique-constraint-vs-unique-index/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/b10b983f383d1fe206d0acbac61cb3c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">s4sql</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server&#8211; Template Explorer</title>
		<link>http://sqlcommitted.com/2012/08/21/sql-server-template-explorer/</link>
		<comments>http://sqlcommitted.com/2012/08/21/sql-server-template-explorer/#comments</comments>
		<pubDate>Tue, 21 Aug 2012 20:04:00 +0000</pubDate>
		<dc:creator>SQLcommitted</dc:creator>
				<category><![CDATA[SQL Info]]></category>
		<category><![CDATA[SSMS Environment Settings]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLcommitted]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[Template]]></category>
		<category><![CDATA[Template Explorer]]></category>
		<category><![CDATA[Transact-SQL]]></category>

		<guid isPermaLink="false">https://sqlcommitted.wordpress.com/?p=304</guid>
		<description><![CDATA[Yesterday when I was about to leave office , I got a call on my mobile from one of my friend. He wanted to know how to write a recursive query? I said use Template Explorer, Where you can get examples for recursive query but He was unaware of this feature of SQL server. So [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=304&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Yesterday when I was about to leave office , I got a call on my mobile from one of my friend. He wanted to know how to write a recursive query? </p>
<p>I said use Template Explorer, Where you can get examples for recursive query but He was unaware of this feature of SQL server. So I thought to write on this.</p>
<p>SQL server provides number of templates which can be used to Create, Alter and Drop different database objects&#160; like Table, Index, Triggers, View and many more. With the help of Template Explorer you can do DDL operation on object as well as you can learn How to write recursive query too. </p>
<p>Follow below steps to open the recursive query example:</p>
<p><strong>Step 1-</strong> Open SQL Server Management Studio </p>
<p><strong>Step 2</strong> – Use shortcut key Ctrl + Alt + T or You can find this option under View-&gt; Template Explorer</p>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/08/image9.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb9.png?w=429&#038;h=450" width="429" height="450" /></a></p>
<p><strong>Step 3</strong>: Expand Recursive Queries section</p>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/08/image10.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb10.png?w=280&#038;h=549" width="280" height="549" /></a></p>
<p>&#160;</p>
<p>We can create our own Custom Template. Refer <a href="http://msdn.microsoft.com/en-us/library/ms166841%28v=sql.105%29.aspx" target="_blank">How to create custom template?</a>. When first time the template explorer is opened, a copy of the templates are placed in the user’s folder in C:\Users, under &lt;username&gt;\AppData\Roaming\Microsoft\SQL Server Management Studio\11.0\Templates. So that all users can have their own copy of templates.</p>
<p>&#160;</p>
<p>If you liked this post, do like on Facebook at <a href="https://www.facebook.com/s4sql">https://www.facebook.com/s4sql</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcommitted.wordpress.com/304/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcommitted.wordpress.com/304/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcommitted.wordpress.com/304/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcommitted.wordpress.com/304/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlcommitted.wordpress.com/304/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlcommitted.wordpress.com/304/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlcommitted.wordpress.com/304/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlcommitted.wordpress.com/304/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcommitted.wordpress.com/304/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcommitted.wordpress.com/304/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcommitted.wordpress.com/304/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcommitted.wordpress.com/304/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcommitted.wordpress.com/304/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcommitted.wordpress.com/304/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=304&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlcommitted.com/2012/08/21/sql-server-template-explorer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/b10b983f383d1fe206d0acbac61cb3c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">s4sql</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb9.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb10.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server &#8211; Join Algorithm</title>
		<link>http://sqlcommitted.com/2012/08/20/sql-server-join-algorithm/</link>
		<comments>http://sqlcommitted.com/2012/08/20/sql-server-join-algorithm/#comments</comments>
		<pubDate>Mon, 20 Aug 2012 03:31:00 +0000</pubDate>
		<dc:creator>SQLcommitted</dc:creator>
				<category><![CDATA[Performance Tips and Tricks]]></category>
		<category><![CDATA[Transact-SQL]]></category>
		<category><![CDATA[Hash Match Join]]></category>
		<category><![CDATA[Inner Join]]></category>
		<category><![CDATA[Join Algorithm]]></category>
		<category><![CDATA[Merge Join]]></category>
		<category><![CDATA[Nested Loop Join]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQLcommitted]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">https://sqlcommitted.wordpress.com/?p=298</guid>
		<description><![CDATA[Today we’ll find how SQL Server works when we do join operation. SQL Server optimizer chooses one of the below physical operator to perform join operation. &#160; Hash Match Merge Join Nested Loop Join As far as performance is concern let me tell you, we can’t say which one is suitable for all kind of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=298&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Today we’ll find how SQL Server works when we do join operation. SQL Server optimizer chooses one of the below physical operator to perform join operation.</p>
<p>&#160;</p>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/08/image1.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb1.png?w=244&#038;h=122" width="244" height="122" /></a></p>
<ul>
<li>Hash Match </li>
<li>Merge Join </li>
<li>Nested Loop Join </li>
</ul>
<p>As far as performance is concern let me tell you, we can’t say which one is suitable for all kind of scenarios. Each operator has its own advantages and disadvantages. Most of the time query optimizer picks the correct physical join operator to perform join operation. Here we’ll find out how these operators works and in which scenario which operator is suitable.</p>
<p>&#160;</p>
<p><strong>Hash Match</strong><a href="http://sqlcommitted.files.wordpress.com/2012/08/hash-match.gif"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="Hash Match" border="0" alt="Hash Match" src="http://sqlcommitted.files.wordpress.com/2012/08/hash-match_thumb.gif?w=93&#038;h=79" width="93" height="79" /></a></p>
<p>Two processes together makes hash join i.e. Build and Probe. Build process create the build input. Optimizer chooses the smaller input to create the build input. During build process , it creates a build hash table by computing a hash value for each row from the build input. Then from the probe input it creates the hash value for applicable rows using same hash function and looks in build hash table for match.&#160;&#160; In case of multiple join on the same join column, these operation are grouped into a hash team. There are 3 types of hash join i.e. in-memory hash join, grace hash join, and recursive hash join. To know more on Hash Join refer <a href="http://technet.microsoft.com/en-us/library/ms189313(v=sql.105)" target="_blank">MSDN</a>.</p>
<table border="1" cellspacing="0" cellpadding="2" width="908">
<tbody>
<tr>
<td valign="top" width="906"><em>Apart from join operation, this operator is used for other operations which includes&#160; <strong>intersection, union, difference, grouping , distinct</strong>.             <br />Hash join algorithm is suitable for large unsorted or non indexed&#160; input.</em></td>
</tr>
</tbody>
</table>
<p>Lets try the below example:</p>
<div class="mycode"></div>
<p>Create two tables,&#160; Table1 and Table1. Insert some records to both the tables.</p>
<div>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0;width:45.73%;font-family:&#039;direction:ltr;height:254px;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;"><span style="color:#0000ff;">Create</span> <span style="color:#0000ff;">Table</span> Table1(Col1 <span style="color:#0000ff;">int</span> <span style="color:#0000ff;">identity</span>, Col2 <span style="color:#0000ff;">varchar</span>(20))<br /><span style="color:#0000ff;">Go</span><br /><span style="color:#0000ff;">Create</span> <span style="color:#0000ff;">Table</span> Table2(Col1 <span style="color:#0000ff;">int</span> <span style="color:#0000ff;">identity</span>, Col2 <span style="color:#0000ff;">varchar</span>(20))<br /><span style="color:#0000ff;">Go</span><br /><br /><span style="color:#0000ff;">Declare</span> @i <span style="color:#0000ff;">int</span> =0<br /><br /><span style="color:#0000ff;">While</span>(@i&lt;10000)<br /><span style="color:#0000ff;">Begin</span><br />  <font color="#0000ff">  Insert</font> Table1 <span style="color:#0000ff;">values</span>( <span style="color:#006080;">'A'</span>+<span style="color:#0000ff;"><font color="#ff00ff">cast</font></span>(@i <span style="color:#0000ff;">as</span> <span style="color:#0000ff;">varchar</span>))<br />    <span style="color:#0000ff;">if</span>(@i%2=0)<br />   <font color="#0000ff"> Insert</font> Table2 <span style="color:#0000ff;">values</span>( <span style="color:#006080;">'A'</span>+<span style="color:#0000ff;"><font color="#ff00ff">cast</font></span>(@i <span style="color:#0000ff;">as</span> <span style="color:#0000ff;">varchar</span>))<br />    <span style="color:#0000ff;">Set</span> @i+=1<br /><span style="color:#0000ff;">End</span><br /><br /><br /></pre>
</div>
<div>&#160;</div>
<div>Press Ctrl+M to show the Actual Execution Plan and execute the below query</div>
<div>&#160;</div>
<div>
<div>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0;width:45.52%;font-family:&#039;direction:ltr;height:60px;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;"><span style="color:#0000ff;">Select</span> T1.Col2<br /><span style="color:#0000ff;">From</span> Table1 T1 <br /><span style="color:#0000ff;">Inner</span> <span style="color:#0000ff;">Join</span> Table2 T2 <span style="color:#0000ff;">ON</span> T1.Col1 = T2.Col1</pre>
</p></div>
<div>&#160;</div>
<div>You can see below the Actual Execution Plan for the above query where Optimizer uses Hash Match Operator to join Table1 and Table2.</div>
<div>Here Optimizer chooses Hash Match operator because of high volume of unsorted input rows. </div>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/08/image2.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb2.png?w=638&#038;h=246" width="638" height="246" /></a></div>
<div>&#160;</div>
<div>If you move your mouse pointer to Hash Match operator , you can see the tool tip as below.</div>
<div>See in the below image, Table2 is used as Build input because Table2 has less number of records compared to Table1 and&#160; Table1 is used as probe input.</div>
<div>&#160;</div>
<div><a href="http://sqlcommitted.files.wordpress.com/2012/08/hash-match-tool-tips.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="Hash Match Tool Tips" border="0" alt="Hash Match Tool Tips" src="http://sqlcommitted.files.wordpress.com/2012/08/hash-match-tool-tips_thumb.jpg?w=325&#038;h=423" width="325" height="423" /></a></div>
<div>&#160;</div>
<div>If we significantly reduce the number of input rows in the above query by applying filter ,&#160; Even though there is no Index defined, Optimizer will use Nested Loop Join operator instead of Hash Match Operator.</div>
<div>&#160;</div>
<div>Lets try the below example,</div>
<div>&#160;</div>
<div>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0;width:48.52%;font-family:&#039;direction:ltr;height:60px;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;"><span style="color:#0000ff;">Select</span>  T1.Col2 <br /><span style="color:#0000ff;">From</span> Table1 T1<br /><span style="color:#0000ff;">Inner</span> <span style="color:#0000ff;">Join</span> Table2 T2 <span style="color:#0000ff;">ON</span> T1.Col1 = T2.Col1 <span style="color:#0000ff;">Where</span> T1.Col1 = 1</pre>
</div>
<div>&#160;</div>
<div>Below is the Actual Execution Plan for the above query, where optimizer chooses Nested Loop Join.</div>
<div>&#160;</div>
<div><a href="http://sqlcommitted.files.wordpress.com/2012/08/image3.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb3.png?w=832&#038;h=267" width="832" height="267" /></a></div>
<div>&#160;</div>
<div>&#160;</div>
<div>&#160;</div>
<div class="mycode"></div>
<div class="mycode"></div>
<p><strong>Merge Join</strong> <a href="http://sqlcommitted.files.wordpress.com/2012/08/merge-join-operator.gif"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="Merge Join Operator" border="0" alt="Merge Join Operator" src="http://sqlcommitted.files.wordpress.com/2012/08/merge-join-operator_thumb.gif?w=85&#038;h=77" width="85" height="77" /></a></p>
<p>Most of the time optimizer chooses Merge Join operator during Join operation when both the inputs are large and sorted on the join column. If Optimizer uses Merge Join, it scans an index if exist on the join column else it applies a sort operator before Merge Join Operator. During Merge Join operation it reads row from each input and compare them. To Know more on Merge Join refer <a href="http://technet.microsoft.com/en-us/library/ms190967(v=sql.105)" target="_blank">MSDN</a> .</p>
<table border="1" cellspacing="0" cellpadding="2" width="1036">
<tbody>
<tr>
<td valign="top" width="1034"><em>Merge Join is possible when the inputs are sorted and not small . The Merge Join operator performs the inner join, left outer join, left semi join, left anti semi join, right outer join, right semi join, right anti semi join, and union logical operations.</em></td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p>Lets try the below example:</p>
<p><strong>Case 1</strong>: Now we know that Merge Join required both inputs should be sorted. Here we’ll apply Merge Join Hint to join Table1 and Table2 to see how optimizer applies sort operator if inputs are not sorted.</p>
<div id="codeSnippetWrapper">
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0;width:52.5%;font-family:&#039;direction:ltr;height:60px;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;"><span style="color:#0000ff;">Select</span>  T1.Col2 <br /><span style="color:#0000ff;">From</span> Table1 T1<br /><span style="color:#0000ff;">Inner</span> Merge <span style="color:#0000ff;">Join</span> Table2 T2 <span style="color:#0000ff;">ON</span> T1.Col1 = T2.Col1 </pre>
<p></div>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/08/image4.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb4.png?w=814&#038;h=253" width="814" height="253" /></a>&#160;</p>
<p>In case you are using Inner Join Operation with out any join hint and if you see your plan is look like above then in that case it is advisable to create index on join columns which will enhance the performance of join operation.</p>
<p><strong>Case 2: </strong>Lets create an Unique Clustered Index on join columns and then will try to join the tables. </p>
<p id="codeSnippetWrapper">
<div id="codeSnippetWrapper">
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0;width:64.95%;font-family:&#039;direction:ltr;height:140px;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;"><span style="color:#0000ff;">Create</span>   <span style="color:#0000ff;">Unique</span> <span style="color:#0000ff;">Clustered</span> <span style="color:#0000ff;">Index</span> IX_Table1_Col1 <span style="color:#0000ff;">ON</span> Table1(Col1)<br /><span style="color:#0000ff;">Go</span><br /><span style="color:#0000ff;">Create</span>   <span style="color:#0000ff;">Unique</span> <span style="color:#0000ff;">Clustered</span> <span style="color:#0000ff;">Index</span> IX_Table2_Col1 <span style="color:#0000ff;">ON</span> Table2(Col1)<br /><span style="color:#0000ff;">Go</span><br /><br /><span style="color:#0000ff;">Select</span>  T1.Col2 <br /><span style="color:#0000ff;">From</span> Table1 T1<br /><span style="color:#0000ff;">Inner</span> <span style="color:#0000ff;">Join</span> Table2 T2 <span style="color:#0000ff;">ON</span> T1.Col1 = T2.Col1</pre>
<p>Even though we are not using any hint in the above query, Optimizer will use Merge Join operator to perform join operation because both inputs are already sorted when we defined&#160; index on the join columns. See below the Actual Execution Plan for the above select query.</p></div>
<div>&#160;</div>
<div><a href="http://sqlcommitted.files.wordpress.com/2012/08/image5.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb5.png?w=802&#038;h=260" width="802" height="260" /></a></div>
<div>&#160;</div>
<div>&#160;</div>
<div>&#160;</div>
<p align="left">&#160;<strong>Nested Loop Join&#160; <a href="http://sqlcommitted.files.wordpress.com/2012/08/nested-loop-join.gif"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="Nested Loop Join" border="0" alt="Nested Loop Join" src="http://sqlcommitted.files.wordpress.com/2012/08/nested-loop-join_thumb.gif?w=92&#038;h=69" width="92" height="69" /></a></strong></p>
<p>This Join is most suitable when outer input is small&#160; and inner input is large and&#160; the join column is indexed. In this kind of join operation it process each row from outer input and loop through all rows of inner input to search for matching row based on join column. To know more refer <a href="http://technet.microsoft.com/en-us/library/ms191318(v=sql.105)" target="_blank">MSDN</a>.</p>
<table border="1" cellspacing="0" cellpadding="2" width="913">
<tbody>
<tr>
<td valign="top" width="911"><em>Nested loops joins perform a search on the inner table for each row of the outer table, typically using an index</em>.<em> The Nested Loops operator performs the inner join, left outer join, left semi join, and left anti semi join logical operations</em></td>
</tr>
</tbody>
</table>
<p>Lets try the below example:</p>
<p>Here we reduce the input rows by applying where clause.</p>
<div id="codeSnippetWrapper">
<div id="codeSnippetWrapper">
<div>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0;width:64.3%;font-family:&#039;direction:ltr;height:80px;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;"><br /><span style="color:#0000ff;">Select</span> T1.Col2<br /><span style="color:#0000ff;">From</span> Table1 T1<br /><span style="color:#0000ff;">Inner</span> <span style="color:#0000ff;">Join</span> Table2 T2 <span style="color:#0000ff;">ON</span> T1.Col1 = T2.Col1 <span style="color:#0000ff;">AND</span> T1.Col1 <span style="color:#0000ff;">between</span> 1 <span style="color:#0000ff;">AND</span> 36</pre>
</p></div>
<div>&#160;</div>
<div>Below is the Actual Execution Plan for the above query.</div>
<div>&#160;</div>
<div><a href="http://sqlcommitted.files.wordpress.com/2012/08/image6.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb6.png?w=843&#038;h=312" width="843" height="312" /></a></div>
</p></div>
<div>&#160;</div>
<div>Now lets compare how it will perform if we apply merge join for the above query. Here I use a range where cost of both the query is same. But if you&#160; compare the Nested Loop operator cost and Merge Join operator cost, Nested Loop operator cost is very much smaller then Merge Join operator cost.</div>
<div>&#160;</div>
<div><a href="http://sqlcommitted.files.wordpress.com/2012/08/image7.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb7.png?w=860&#038;h=372" width="860" height="372" /></a></div>
<div>&#160;</div>
</div>
<p>For the above query we can’t say which operator is efficient. Now lets reduce the number of input rows and will see how it perform.</p>
<div id="codeSnippetWrapper">
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;margin:0;width:81.59%;font-family:&#039;direction:ltr;height:120px;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;"><span style="color:#0000ff;">Select</span> T1.Col2<br /><span style="color:#0000ff;">From</span> Table1 T1<br /><span style="color:#0000ff;">Inner</span> <span style="color:#0000ff;">Join</span> Table2 T2 <span style="color:#0000ff;">ON</span> T1.Col1 = T2.Col1 <span style="color:#0000ff;">AND</span> T1.Col1 <span style="color:#0000ff;">between</span> 1 <span style="color:#0000ff;">AND</span> 15<br /><br /><span style="color:#0000ff;">Select</span> T1.Col2<br /><span style="color:#0000ff;">From</span> Table1 T1<br /><span style="color:#0000ff;">Inner</span> Merge <span style="color:#0000ff;">Join</span> Table2 T2 <span style="color:#0000ff;">ON</span> T1.Col1 = T2.Col1 <span style="color:#0000ff;">AND</span> T1.Col1 <span style="color:#0000ff;">between</span> 1 <span style="color:#0000ff;">AND</span> 15</pre>
<p></div>
<p>Below is the Actual Execution Plan for the above query.</p>
<p><a href="http://sqlcommitted.files.wordpress.com/2012/08/image8.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" border="0" alt="image" src="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb8.png?w=870&#038;h=408" width="870" height="408" /></a></p>
<p>In the above screenshot we can see when the number of input is small Nested Loop Join perform better.</p>
<p>&#160;</p>
<p>All of the above join operators perform well based on the criteria. We can’t say which one is better. </p>
<p>Can you answer to the below question?</p>
<p>To demonstrate merge join Why I created Unique Clustered Index? What will happen If I create Clustered Index without Unique key word?</p>
<p>Reference : <a href="http://technet.microsoft.com/en-us/library/ms191426%28v=sql.105%29" target="_blank">MSDN</a></p>
<p>If you liked this post, do like on Facebook at <a href="https://www.facebook.com/s4sql">https://www.facebook.com/s4sql</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcommitted.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcommitted.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcommitted.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcommitted.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlcommitted.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlcommitted.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlcommitted.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlcommitted.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcommitted.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcommitted.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcommitted.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcommitted.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcommitted.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcommitted.wordpress.com/298/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcommitted.com&#038;blog=30816729&#038;post=298&#038;subd=sqlcommitted&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sqlcommitted.com/2012/08/20/sql-server-join-algorithm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/b10b983f383d1fe206d0acbac61cb3c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">s4sql</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/08/hash-match_thumb.gif" medium="image">
			<media:title type="html">Hash Match</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/08/hash-match-tool-tips_thumb.jpg" medium="image">
			<media:title type="html">Hash Match Tool Tips</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/08/merge-join-operator_thumb.gif" medium="image">
			<media:title type="html">Merge Join Operator</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb5.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/08/nested-loop-join_thumb.gif" medium="image">
			<media:title type="html">Nested Loop Join</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb6.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb7.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://sqlcommitted.files.wordpress.com/2012/08/image_thumb8.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
	</channel>
</rss>
