<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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: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>Comments on: SQL SERVER &#8211; SELECT 1 vs SELECT * &#8211; An Interesting Observation</title>
	<atom:link href="http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: X-coder</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-473930</link>
		<dc:creator><![CDATA[X-coder]]></dc:creator>
		<pubDate>Sun, 12 May 2013 17:55:12 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-473930</guid>
		<description><![CDATA[Great Post.......]]></description>
		<content:encoded><![CDATA[<p>Great Post&#8230;&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vini</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-471912</link>
		<dc:creator><![CDATA[vini]]></dc:creator>
		<pubDate>Thu, 09 May 2013 10:42:59 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-471912</guid>
		<description><![CDATA[i just run select 1 from  in DB2 it is showing 1,1,1,1,1... nothing more then that,even i tryd at SQL server too, same result , i dont knw how any y u guys comparing results ???]]></description>
		<content:encoded><![CDATA[<p>i just run select 1 from  in DB2 it is showing 1,1,1,1,1&#8230; nothing more then that,even i tryd at SQL server too, same result , i dont knw how any y u guys comparing results ???</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #018 &#124; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-430054</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #018 &#124; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Sat, 02 Mar 2013 01:30:46 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-430054</guid>
		<description><![CDATA[[...] SELECT 1 vs SELECT * – An Interesting Observation Many times I have seen the issue of SELECT 1 vs SELECT * discussed in terms of performance or readability while checking for the existence of rows in the table. I ran quick 4 tests about this observed that I am getting same result when used SELECT 1 and SELECT *. I think smart readers of this blog will come up the situation when SELECT 1 and SELECT * have a different execution plan when used to find existence of rows. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SELECT 1 vs SELECT * – An Interesting Observation Many times I have seen the issue of SELECT 1 vs SELECT * discussed in terms of performance or readability while checking for the existence of rows in the table. I ran quick 4 tests about this observed that I am getting same result when used SELECT 1 and SELECT *. I think smart readers of this blog will come up the situation when SELECT 1 and SELECT * have a different execution plan when used to find existence of rows. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ankit@Android</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-407487</link>
		<dc:creator><![CDATA[Ankit@Android]]></dc:creator>
		<pubDate>Mon, 14 Jan 2013 08:22:28 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-407487</guid>
		<description><![CDATA[SELECT 1 helped me fairly well]]></description>
		<content:encoded><![CDATA[<p>SELECT 1 helped me fairly well</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-314659</link>
		<dc:creator><![CDATA[Phil]]></dc:creator>
		<pubDate>Tue, 17 Jul 2012 16:37:00 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-314659</guid>
		<description><![CDATA[I don&#039;t believe this debate will ever end :) 
I have been asked more than once about the performance difference between EXISTS(SELECT * and EXISTS(SELECT 1.  Since I deal almost exclusively with Microsoft SQL Server I have always pointed to the documentation Greg Jorgensen referred to (July 20, 2009), i.e. these days it comes down to personal preference.  The whole point here is that the parser knows whether or not any real data is needed when the subquery is in an EXISTS, AFAIK SQL Server has treated EXISTS SELECT * as &quot;SELECT anything&quot; since at least version 7.0  (6.5 was the Sybase root/MS split).  Any SQL database optimizer should be able to predict if retrieving meta-data is needed ot not.
So for me there are 2 interpretations of SELECT *, if inside an EXISTS it is &quot;SELECT anything&quot;, outside is &quot;SELECT ALL&quot;, and any instance of &quot;SELECT ALL&quot; better have a good reason for its existance.

BTW, I recently asked a newer co-worker why he used &quot;SELECT 1&quot;, his response was &quot;I was taught that way&quot;.  The good news is he was also taught that &quot;SELECT *&quot; is bad, but unfortunately teaching good or bad with no explanation as to when or why is one of the reasons this thread exists.]]></description>
		<content:encoded><![CDATA[<p>I don&#8217;t believe this debate will ever end :)<br />
I have been asked more than once about the performance difference between EXISTS(SELECT * and EXISTS(SELECT 1.  Since I deal almost exclusively with Microsoft SQL Server I have always pointed to the documentation Greg Jorgensen referred to (July 20, 2009), i.e. these days it comes down to personal preference.  The whole point here is that the parser knows whether or not any real data is needed when the subquery is in an EXISTS, AFAIK SQL Server has treated EXISTS SELECT * as &#8220;SELECT anything&#8221; since at least version 7.0  (6.5 was the Sybase root/MS split).  Any SQL database optimizer should be able to predict if retrieving meta-data is needed ot not.<br />
So for me there are 2 interpretations of SELECT *, if inside an EXISTS it is &#8220;SELECT anything&#8221;, outside is &#8220;SELECT ALL&#8221;, and any instance of &#8220;SELECT ALL&#8221; better have a good reason for its existance.</p>
<p>BTW, I recently asked a newer co-worker why he used &#8220;SELECT 1&#8243;, his response was &#8220;I was taught that way&#8221;.  The good news is he was also taught that &#8220;SELECT *&#8221; is bad, but unfortunately teaching good or bad with no explanation as to when or why is one of the reasons this thread exists.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hootsey</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-243409</link>
		<dc:creator><![CDATA[hootsey]]></dc:creator>
		<pubDate>Wed, 25 Jan 2012 11:34:41 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-243409</guid>
		<description><![CDATA[To add to this comment on the history of why select 1 is used. select * certainly used to have physical disk IO implications that take time reading the data where as selecting a constant didn&#039;t. This probably isn&#039;t the case now but I still use select 1]]></description>
		<content:encoded><![CDATA[<p>To add to this comment on the history of why select 1 is used. select * certainly used to have physical disk IO implications that take time reading the data where as selecting a constant didn&#8217;t. This probably isn&#8217;t the case now but I still use select 1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-168780</link>
		<dc:creator><![CDATA[Tony]]></dc:creator>
		<pubDate>Fri, 16 Sep 2011 16:37:03 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-168780</guid>
		<description><![CDATA[A bit of history that we all know that SQL Server came from Sybase and that optimizers were not always as good as they are now. So these products have evoloved and been continually enhance over a period of over 20 years.  These &quot;Myths&quot; started many moons ago. I clearly rmember having issues with SQL 6.5 doing EXISTS(SELECT * FROM ...) and fixing these issues by using SELECT 1.  The Optimizers now don&#039;t have these issues but I still use SELECT 1 because vehemently dislike the use of SELECT * in any scenario.]]></description>
		<content:encoded><![CDATA[<p>A bit of history that we all know that SQL Server came from Sybase and that optimizers were not always as good as they are now. So these products have evoloved and been continually enhance over a period of over 20 years.  These &#8220;Myths&#8221; started many moons ago. I clearly rmember having issues with SQL 6.5 doing EXISTS(SELECT * FROM &#8230;) and fixing these issues by using SELECT 1.  The Optimizers now don&#8217;t have these issues but I still use SELECT 1 because vehemently dislike the use of SELECT * in any scenario.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-155362</link>
		<dc:creator><![CDATA[Joe]]></dc:creator>
		<pubDate>Tue, 09 Aug 2011 10:02:04 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-155362</guid>
		<description><![CDATA[An advantage of using select 1 instead of select * is that you can do a simple find in your code base and any &#039;select *&#039; will raise a red flag and a visit to the offending developer&#039;s desk :-) A workaround is searching with a regular expression to exclude cases with &#039;exists (&#039; but my regular expression brain can&#039;t figure this out in 2 minutes :-)]]></description>
		<content:encoded><![CDATA[<p>An advantage of using select 1 instead of select * is that you can do a simple find in your code base and any &#8216;select *&#8217; will raise a red flag and a visit to the offending developer&#8217;s desk :-) A workaround is searching with a regular expression to exclude cases with &#8216;exists (&#8216; but my regular expression brain can&#8217;t figure this out in 2 minutes :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rajan</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-124402</link>
		<dc:creator><![CDATA[Rajan]]></dc:creator>
		<pubDate>Tue, 22 Mar 2011 15:17:04 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-124402</guid>
		<description><![CDATA[I believe, select 1 is faster if the condition is checking the indexed columns.
In that case, we don&#039;t need to fetch the data from the FS, only read the index(which is the step used anyway) and if true, then output 1. This reduces the step to fetch data from underlying FS

-R]]></description>
		<content:encoded><![CDATA[<p>I believe, select 1 is faster if the condition is checking the indexed columns.<br />
In that case, we don&#8217;t need to fetch the data from the FS, only read the index(which is the step used anyway) and if true, then output 1. This reduces the step to fetch data from underlying FS</p>
<p>-R</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yeoh Ray Mond</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-81635</link>
		<dc:creator><![CDATA[Yeoh Ray Mond]]></dc:creator>
		<pubDate>Sun, 25 Jul 2010 16:00:51 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-81635</guid>
		<description><![CDATA[Well, I&#039;ve always used EXISTS 1, simply because it is easier to type compared to *!]]></description>
		<content:encoded><![CDATA[<p>Well, I&#8217;ve always used EXISTS 1, simply because it is easier to type compared to *!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-62927</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Mon, 15 Mar 2010 07:16:11 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-62927</guid>
		<description><![CDATA[In the Query Analyser PRESS CONTROL+L]]></description>
		<content:encoded><![CDATA[<p>In the Query Analyser PRESS CONTROL+L</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-62926</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Mon, 15 Mar 2010 07:13:23 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-62926</guid>
		<description><![CDATA[If you used Transaction, you can rollback it
Otherwise restore the latest backup you have]]></description>
		<content:encoded><![CDATA[<p>If you used Transaction, you can rollback it<br />
Otherwise restore the latest backup you have</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rsenna</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-62675</link>
		<dc:creator><![CDATA[rsenna]]></dc:creator>
		<pubDate>Wed, 10 Mar 2010 19:45:46 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-62675</guid>
		<description><![CDATA[@Dan

I still believe Greg Jorgensen was right on that one.

To be sure that a value DOESN&#039;T exist, the engine must do a full scan. To be sure that a value exists, finding the first is enough. And if there is proper index, the scan will use it.

So, if you execute a WHERE X = 2 on a table completely filled of 1&#039;s, a full scan will happen either way - doesn&#039;t matter if you were using a EXISTS or a NOT EXISTS. The engine should work exactly the same way in both cases.]]></description>
		<content:encoded><![CDATA[<p>@Dan</p>
<p>I still believe Greg Jorgensen was right on that one.</p>
<p>To be sure that a value DOESN&#8217;T exist, the engine must do a full scan. To be sure that a value exists, finding the first is enough. And if there is proper index, the scan will use it.</p>
<p>So, if you execute a WHERE X = 2 on a table completely filled of 1&#8242;s, a full scan will happen either way &#8211; doesn&#8217;t matter if you were using a EXISTS or a NOT EXISTS. The engine should work exactly the same way in both cases.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-61612</link>
		<dc:creator><![CDATA[Dan]]></dc:creator>
		<pubDate>Tue, 23 Feb 2010 03:16:12 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-61612</guid>
		<description><![CDATA[Greg Jorgensen said:

&quot;EXISTS and NOT EXISTS do the same work&quot;

This is not necessarily true.  Depending on the indexes being used (or not used), an EXISTS may be faster, because it can stop as soon as it finds one matching row.  A NOT EXISTS may have to table scan the entire table (if there&#039;s no index that helps the query).]]></description>
		<content:encoded><![CDATA[<p>Greg Jorgensen said:</p>
<p>&#8220;EXISTS and NOT EXISTS do the same work&#8221;</p>
<p>This is not necessarily true.  Depending on the indexes being used (or not used), an EXISTS may be faster, because it can stop as soon as it finds one matching row.  A NOT EXISTS may have to table scan the entire table (if there&#8217;s no index that helps the query).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-61423</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Thu, 18 Feb 2010 13:10:12 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-61423</guid>
		<description><![CDATA[Siva,

You need to have a valid backup in advance or you may need some third party tools]]></description>
		<content:encoded><![CDATA[<p>Siva,</p>
<p>You need to have a valid backup in advance or you may need some third party tools</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: siva</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-56756</link>
		<dc:creator><![CDATA[siva]]></dc:creator>
		<pubDate>Fri, 16 Oct 2009 13:44:46 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-56756</guid>
		<description><![CDATA[How do we get back the data that we have deleted from a table?]]></description>
		<content:encoded><![CDATA[<p>How do we get back the data that we have deleted from a table?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Short</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-53968</link>
		<dc:creator><![CDATA[Jason Short]]></dc:creator>
		<pubDate>Wed, 22 Jul 2009 18:19:45 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-53968</guid>
		<description><![CDATA[I would not call it a bug if they were not the same under the hood.  The optimizer can only guess so much.  It really depends on how the statements are written.  The ones above are pretty simple and should optimize well, but not all are that easily second guessed as to their intent.]]></description>
		<content:encoded><![CDATA[<p>I would not call it a bug if they were not the same under the hood.  The optimizer can only guess so much.  It really depends on how the statements are written.  The ones above are pretty simple and should optimize well, but not all are that easily second guessed as to their intent.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evan Carroll</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-53884</link>
		<dc:creator><![CDATA[Evan Carroll]]></dc:creator>
		<pubDate>Mon, 20 Jul 2009 15:23:46 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-53884</guid>
		<description><![CDATA[I would call it a fairly major bug in the query engine if SELECT 1, and SELECT * were not optimized to do the same thing when the context is within the EXIST() statement. Certainly, there is no practical reason why you would visit any extra meta data at all if exists is just going to return a SQL bool..]]></description>
		<content:encoded><![CDATA[<p>I would call it a fairly major bug in the query engine if SELECT 1, and SELECT * were not optimized to do the same thing when the context is within the EXIST() statement. Certainly, there is no practical reason why you would visit any extra meta data at all if exists is just going to return a SQL bool..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sangam Uprety</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-53865</link>
		<dc:creator><![CDATA[Sangam Uprety]]></dc:creator>
		<pubDate>Mon, 20 Jul 2009 09:43:21 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-53865</guid>
		<description><![CDATA[Simple issue and much discussions. And good one! Since in much cases we have to execute the EXISTS, using faster one [may be only fractions of second faster] matters. My preference is using SELECT 1, however. Thanks.]]></description>
		<content:encoded><![CDATA[<p>Simple issue and much discussions. And good one! Since in much cases we have to execute the EXISTS, using faster one [may be only fractions of second faster] matters. My preference is using SELECT 1, however. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Jorgensen</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-53844</link>
		<dc:creator><![CDATA[Greg Jorgensen]]></dc:creator>
		<pubDate>Sun, 19 Jul 2009 20:36:10 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-53844</guid>
		<description><![CDATA[Lutz:

EXISTS and NOT EXISTS do the same work: the db engine only has to find a single row that matches the WHERE clause in the subquery to satisfy the test. The syntax gives it aways: NOT EXISTS is the logical NOT of the EXISTS test.

Depending on the subquery WHERE condition the existence of at least one matching row may be answered by scanning an index, or it may require a table scan. In either case as soon as a single matching row is found the result of EXISTS is known. The result of NOT EXISTS is simply the logical inverse of the result of EXISTS.

In your example the subquery inside the EXISTS() doesn&#039;t &quot;return approx. 1 million rows.&quot; It doesn&#039;t return any rows -- it returns a TRUE or FALSE. The db engine can give the result when it encounters the first row matching the WHERE clause. There is no result set to discard for the subquery.

If you are seeing different results using SELECT 1 vs. SELECT * it&#039;s probably due to SELECT * having done all the work and cached the indexes so SELECT 1 has less work to do.]]></description>
		<content:encoded><![CDATA[<p>Lutz:</p>
<p>EXISTS and NOT EXISTS do the same work: the db engine only has to find a single row that matches the WHERE clause in the subquery to satisfy the test. The syntax gives it aways: NOT EXISTS is the logical NOT of the EXISTS test.</p>
<p>Depending on the subquery WHERE condition the existence of at least one matching row may be answered by scanning an index, or it may require a table scan. In either case as soon as a single matching row is found the result of EXISTS is known. The result of NOT EXISTS is simply the logical inverse of the result of EXISTS.</p>
<p>In your example the subquery inside the EXISTS() doesn&#8217;t &#8220;return approx. 1 million rows.&#8221; It doesn&#8217;t return any rows &#8212; it returns a TRUE or FALSE. The db engine can give the result when it encounters the first row matching the WHERE clause. There is no result set to discard for the subquery.</p>
<p>If you are seeing different results using SELECT 1 vs. SELECT * it&#8217;s probably due to SELECT * having done all the work and cached the indexes so SELECT 1 has less work to do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Jorgensen</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-53843</link>
		<dc:creator><![CDATA[Greg Jorgensen]]></dc:creator>
		<pubDate>Sun, 19 Jul 2009 20:26:21 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-53843</guid>
		<description><![CDATA[This shouldn&#039;t be such a mysterious of contentious subject. SELECT * in an EXISTS condition is a SQL idiom. In this context * means &quot;I don&#039;t care about the columns,&quot; not &quot;fetch all columns.&quot; It may or may not be optimized by the compiler depending on the dialect of SQL. Apparently T-SQL is smart in this regard but other RDBMSs may special-case SELECT * in subqueries.

The Microsoft SQL Server documentation says this:

&quot;The select list of a subquery introduced with EXISTS, by convention, has an asterisk (*) instead of a single column name. The rules for a subquery introduced with EXISTS are the same as those for a standard select list, because a subquery introduced with EXISTS creates an existence test and returns TRUE or FALSE, instead of data.&quot; (T-SQL reference, Subquery Rules).

Anyone who knows SQL should recognize the idiom EXISTS(SELECT * ...). The alternative EXISTS(SELECT 1 ...) is obvious but not really idiomatic. Anything else is just showing off and making the SQL harder for the next person to understand.]]></description>
		<content:encoded><![CDATA[<p>This shouldn&#8217;t be such a mysterious of contentious subject. SELECT * in an EXISTS condition is a SQL idiom. In this context * means &#8220;I don&#8217;t care about the columns,&#8221; not &#8220;fetch all columns.&#8221; It may or may not be optimized by the compiler depending on the dialect of SQL. Apparently T-SQL is smart in this regard but other RDBMSs may special-case SELECT * in subqueries.</p>
<p>The Microsoft SQL Server documentation says this:</p>
<p>&#8220;The select list of a subquery introduced with EXISTS, by convention, has an asterisk (*) instead of a single column name. The rules for a subquery introduced with EXISTS are the same as those for a standard select list, because a subquery introduced with EXISTS creates an existence test and returns TRUE or FALSE, instead of data.&#8221; (T-SQL reference, Subquery Rules).</p>
<p>Anyone who knows SQL should recognize the idiom EXISTS(SELECT * &#8230;). The alternative EXISTS(SELECT 1 &#8230;) is obvious but not really idiomatic. Anything else is just showing off and making the SQL harder for the next person to understand.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Guidelines and Coding Standards Part - 1 Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-47500</link>
		<dc:creator><![CDATA[SQL SERVER - Guidelines and Coding Standards Part - 1 Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Thu, 26 Feb 2009 12:13:52 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-47500</guid>
		<description><![CDATA[[...] Indent code for better readability. (Example) [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Indent code for better readability. (Example) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Palanisamy</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-46444</link>
		<dc:creator><![CDATA[Palanisamy]]></dc:creator>
		<pubDate>Sun, 08 Feb 2009 06:57:29 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-46444</guid>
		<description><![CDATA[Hi Pinal,
            How can we see the &quot;excution Plan&quot;????

Regards,
Palanisamy]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
            How can we see the &#8220;excution Plan&#8221;????</p>
<p>Regards,<br />
Palanisamy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rohit</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-46427</link>
		<dc:creator><![CDATA[rohit]]></dc:creator>
		<pubDate>Sat, 07 Feb 2009 13:37:40 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-46427</guid>
		<description><![CDATA[how do we get back the data that we ve deleted from a table??]]></description>
		<content:encoded><![CDATA[<p>how do we get back the data that we ve deleted from a table??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rao K</title>
		<link>http://blog.sqlauthority.com/2008/02/26/sql-server-select-1-vs-select-an-interesting-observation/#comment-44561</link>
		<dc:creator><![CDATA[Rao K]]></dc:creator>
		<pubDate>Fri, 05 Dec 2008 17:39:42 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=519#comment-44561</guid>
		<description><![CDATA[What is the equallent in SQL Server for 

select * from table1 a
where (a.x, a.y) in (
select b.x, min(b.y)
from table1 b
group by b.x
)]]></description>
		<content:encoded><![CDATA[<p>What is the equallent in SQL Server for </p>
<p>select * from table1 a<br />
where (a.x, a.y) in (<br />
select b.x, min(b.y)<br />
from table1 b<br />
group by b.x<br />
)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
