<?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; Puzzle &#8211; SELECT * vs SELECT COUNT(*)</title>
	<atom:link href="http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/</link>
	<description>SQL, SQL Server, MySQL, Big Data and NoSQL</description>
	<lastBuildDate>Wed, 19 Jun 2013 15:04:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #031 &#124; Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-486728</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #031 &#124; Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Sat, 01 Jun 2013 01:31:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-486728</guid>
		<description><![CDATA[[&#8230;] Puzzle – SELECT * vs SELECT COUNT(*) If you have ever wondered SELECT * gives error when executed alone but SELECT COUNT(*) does not. Why? in that case, you should read this blog post. [&#8230;]]]></description>
		<content:encoded><![CDATA[<p>[&#8230;] Puzzle – SELECT * vs SELECT COUNT(*) If you have ever wondered SELECT * gives error when executed alone but SELECT COUNT(*) does not. Why? in that case, you should read this blog post. [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rahul Singi</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-444250</link>
		<dc:creator><![CDATA[Rahul Singi]]></dc:creator>
		<pubDate>Mon, 25 Mar 2013 18:17:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-444250</guid>
		<description><![CDATA[Select Count(*) is treating it self as SELECT 1. Means Select . While SELECT * is incomplete syntax It is looking for the table or some object which is equivalent to table.]]></description>
		<content:encoded><![CDATA[<p>Select Count(*) is treating it self as SELECT 1. Means Select . While SELECT * is incomplete syntax It is looking for the table or some object which is equivalent to table.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prasad</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-444241</link>
		<dc:creator><![CDATA[Prasad]]></dc:creator>
		<pubDate>Mon, 25 Mar 2013 18:01:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-444241</guid>
		<description><![CDATA[When you give Select Count(*) it scans an internal table of constants with 1 row, so it returns result as 1. Check the Execution plan.]]></description>
		<content:encoded><![CDATA[<p>When you give Select Count(*) it scans an internal table of constants with 1 row, so it returns result as 1. Check the Execution plan.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sanjay Monpara</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-295076</link>
		<dc:creator><![CDATA[Sanjay Monpara]]></dc:creator>
		<pubDate>Wed, 06 Jun 2012 05:42:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-295076</guid>
		<description><![CDATA[when we are using count(*) function with select statement then Sql Server internally using dummy table which have one column (like oracle&#039;s Dual table)]]></description>
		<content:encoded><![CDATA[<p>when we are using count(*) function with select statement then Sql Server internally using dummy table which have one column (like oracle&#8217;s Dual table)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Tricks to Replace SELECT * with Column Names &#8211; SQL in Sixty Seconds #017 &#8211; Video &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-294962</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Tricks to Replace SELECT * with Column Names &#8211; SQL in Sixty Seconds #017 &#8211; Video &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Wed, 06 Jun 2012 01:31:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-294962</guid>
		<description><![CDATA[[...] SQL SERVER – Puzzle – SELECT * vs SELECT COUNT(*) [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER – Puzzle – SELECT * vs SELECT COUNT(*) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob Farley</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-258428</link>
		<dc:creator><![CDATA[Rob Farley]]></dc:creator>
		<pubDate>Fri, 02 Mar 2012 05:39:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-258428</guid>
		<description><![CDATA[There are a few things you can put in COUNT().

COUNT(*)
COUNT(1)
COUNT(Column)
COUNT(DISTINCT Column)

COUNT(DISTINCT Column) looks for distinct values in the column, so it has a bunch of extra work to do.
COUNT(Column) looks for non-null values in that column, so it still has to read through it, unless the column doesn&#039;t allow null, in which case it really just has to think about how many rows there are.
So COUNT(1) sounds very similar to COUNT(Column) when Column doesn&#039;t allow nulls - but SQL sees it&#039;s a constant and handles it as such, just counting rows.
And COUNT(*) is a recognised pattern which is understood as &quot;just count rows&quot;.

So COUNT(1) and COUNT(*) should be regarded as the same. I prefer COUNT(*) as it&#039;s considered a recognised pattern. I never both using COUNT(1) - especialy since if you&#039;re doing something like SUM(CASE...END), then you might have values of 1, 0, -1, whatever, being produced by your CASE statement, and so when I see COUNT(1), I have to start wondering whether it&#039;s actually what I want or not. Plus, the old &quot;ORDER BY 1&quot; gives meaning to the 1, and I don&#039;t want any kind of confusion around that either.

Hope this helps,

Rob]]></description>
		<content:encoded><![CDATA[<p>There are a few things you can put in COUNT().</p>
<p>COUNT(*)<br />
COUNT(1)<br />
COUNT(Column)<br />
COUNT(DISTINCT Column)</p>
<p>COUNT(DISTINCT Column) looks for distinct values in the column, so it has a bunch of extra work to do.<br />
COUNT(Column) looks for non-null values in that column, so it still has to read through it, unless the column doesn&#8217;t allow null, in which case it really just has to think about how many rows there are.<br />
So COUNT(1) sounds very similar to COUNT(Column) when Column doesn&#8217;t allow nulls &#8211; but SQL sees it&#8217;s a constant and handles it as such, just counting rows.<br />
And COUNT(*) is a recognised pattern which is understood as &#8220;just count rows&#8221;.</p>
<p>So COUNT(1) and COUNT(*) should be regarded as the same. I prefer COUNT(*) as it&#8217;s considered a recognised pattern. I never both using COUNT(1) &#8211; especialy since if you&#8217;re doing something like SUM(CASE&#8230;END), then you might have values of 1, 0, -1, whatever, being produced by your CASE statement, and so when I see COUNT(1), I have to start wondering whether it&#8217;s actually what I want or not. Plus, the old &#8220;ORDER BY 1&#8243; gives meaning to the 1, and I don&#8217;t want any kind of confusion around that either.</p>
<p>Hope this helps,</p>
<p>Rob</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lolita</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-258316</link>
		<dc:creator><![CDATA[lolita]]></dc:creator>
		<pubDate>Thu, 01 Mar 2012 19:20:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-258316</guid>
		<description><![CDATA[Hi, 
I have a question : 

what is the different between COUNT(*) and COUNT(1) which is better regarding performance and optimization ?


Thank you,]]></description>
		<content:encoded><![CDATA[<p>Hi,<br />
I have a question : </p>
<p>what is the different between COUNT(*) and COUNT(1) which is better regarding performance and optimization ?</p>
<p>Thank you,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bijuks</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-165936</link>
		<dc:creator><![CDATA[bijuks]]></dc:creator>
		<pubDate>Tue, 06 Sep 2011 09:47:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-165936</guid>
		<description><![CDATA[Thank you Kumar Harsh ....!]]></description>
		<content:encoded><![CDATA[<p>Thank you Kumar Harsh &#8230;.!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kumar Harsh</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-165848</link>
		<dc:creator><![CDATA[Kumar Harsh]]></dc:creator>
		<pubDate>Tue, 06 Sep 2011 04:27:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-165848</guid>
		<description><![CDATA[I think count function expect table or variable.
Select count(null)-- Here count is not able to identify table or variable

Second example do not give error.
also count do not count null values.It shows 0 for it.
in your example,if values of @A is 0 or above then its count is 1.
See one more example,

declare @t table(a varchar(10))
insert into @t values (null)
insert into @t values (&#039;&#039;)
insert into @t values (&#039;abc&#039;)
Select COUNT(a) from @t  --Output is 2 because count() do not count null values

If we write,
Select count(*) from @t--Output is 3,because here we are telling count() to provide number of rows.]]></description>
		<content:encoded><![CDATA[<p>I think count function expect table or variable.<br />
Select count(null)&#8211; Here count is not able to identify table or variable</p>
<p>Second example do not give error.<br />
also count do not count null values.It shows 0 for it.<br />
in your example,if values of @A is 0 or above then its count is 1.<br />
See one more example,</p>
<p>declare @t table(a varchar(10))<br />
insert into @t values (null)<br />
insert into @t values (&#8221;)<br />
insert into @t values (&#8216;abc&#8217;)<br />
Select COUNT(a) from @t  &#8211;Output is 2 because count() do not count null values</p>
<p>If we write,<br />
Select count(*) from @t&#8211;Output is 3,because here we are telling count() to provide number of rows.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BijuKS</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-165660</link>
		<dc:creator><![CDATA[BijuKS]]></dc:creator>
		<pubDate>Mon, 05 Sep 2011 13:09:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-165660</guid>
		<description><![CDATA[Hi All,

I have one question :)
Please execute the following Queries…!

SELECT COUNT(NULL) -- this will generate error

GO

DECLARE @A INT
SET @A=NULL
SELECT COUNT(@A) --–this will not generate error why??]]></description>
		<content:encoded><![CDATA[<p>Hi All,</p>
<p>I have one question :)<br />
Please execute the following Queries…!</p>
<p>SELECT COUNT(NULL) &#8212; this will generate error</p>
<p>GO</p>
<p>DECLARE @A INT<br />
SET @A=NULL<br />
SELECT COUNT(@A) &#8211;–this will not generate error why??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lalit</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-143713</link>
		<dc:creator><![CDATA[lalit]]></dc:creator>
		<pubDate>Sat, 25 Jun 2011 17:57:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-143713</guid>
		<description><![CDATA[Hi Pinal,

i am new to sql server and was browsing for the solution. 
found a link in msdn
http://social.msdn.microsoft.com/forums/en-US/transactsql/thread/feba220c-4b43-4401-9711-e55198cff39e/
so do you agree with those comments??]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>i am new to sql server and was browsing for the solution.<br />
found a link in msdn<br />
<a href="http://social.msdn.microsoft.com/forums/en-US/transactsql/thread/feba220c-4b43-4401-9711-e55198cff39e/" rel="nofollow">http://social.msdn.microsoft.com/forums/en-US/transactsql/thread/feba220c-4b43-4401-9711-e55198cff39e/</a><br />
so do you agree with those comments??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lalit Gada</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-143600</link>
		<dc:creator><![CDATA[Lalit Gada]]></dc:creator>
		<pubDate>Sat, 25 Jun 2011 04:57:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-143600</guid>
		<description><![CDATA[Select Count(*) is an aggregate function used to detrmine the number of times the argument occurs, it will return 1 as default.

Select * will throw an error because * is  a wild character and not a function and function returns a value.]]></description>
		<content:encoded><![CDATA[<p>Select Count(*) is an aggregate function used to detrmine the number of times the argument occurs, it will return 1 as default.</p>
<p>Select * will throw an error because * is  a wild character and not a function and function returns a value.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RAJESH KUMAR JAISWAL</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-142980</link>
		<dc:creator><![CDATA[RAJESH KUMAR JAISWAL]]></dc:creator>
		<pubDate>Wed, 22 Jun 2011 13:04:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-142980</guid>
		<description><![CDATA[hi,

plz anybody reply me,

i got an error of 14262 in log shipping configuration

actually what i done is iam just started using sql server 2005, i configured the logshipping by using two instances of sql 2005 , instead of disabling the logshipping i deleted the jobs then again when i went to configure logshipping it is not possible i got an error of 14262.(email removed)]]></description>
		<content:encoded><![CDATA[<p>hi,</p>
<p>plz anybody reply me,</p>
<p>i got an error of 14262 in log shipping configuration</p>
<p>actually what i done is iam just started using sql server 2005, i configured the logshipping by using two instances of sql 2005 , instead of disabling the logshipping i deleted the jobs then again when i went to configure logshipping it is not possible i got an error of 14262.(email removed)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: atul</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-141821</link>
		<dc:creator><![CDATA[atul]]></dc:creator>
		<pubDate>Sat, 18 Jun 2011 06:40:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-141821</guid>
		<description><![CDATA[COUNT  always return a integer value  because it return number of rows]]></description>
		<content:encoded><![CDATA[<p>COUNT  always return a integer value  because it return number of rows</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: praveenT</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-141811</link>
		<dc:creator><![CDATA[praveenT]]></dc:creator>
		<pubDate>Sat, 18 Jun 2011 05:51:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-141811</guid>
		<description><![CDATA[In My view,
According to C++ ‘*’(asterick) is De reference operator which means “point to” the variable whose reference they store. it requires a reference. so here i mean in SQL we refer a tablename
And Count() is behaves like a function it requires 1 argument.
For ex: select count(0) in place of count(*) it returns a value.]]></description>
		<content:encoded><![CDATA[<p>In My view,<br />
According to C++ ‘*’(asterick) is De reference operator which means “point to” the variable whose reference they store. it requires a reference. so here i mean in SQL we refer a tablename<br />
And Count() is behaves like a function it requires 1 argument.<br />
For ex: select count(0) in place of count(*) it returns a value.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: praveenT</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-141809</link>
		<dc:creator><![CDATA[praveenT]]></dc:creator>
		<pubDate>Sat, 18 Jun 2011 05:50:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-141809</guid>
		<description><![CDATA[In My view,
According to C++ ‘*’(asterick) is De reference operator which means “point to” the variable whose reference they store. it requires a reference. so here i mean in SQL we refer a 
And Count() is behaves like a function it requires 1 argument.
For ex: select count(0) in place of count(*) it returns a value.]]></description>
		<content:encoded><![CDATA[<p>In My view,<br />
According to C++ ‘*’(asterick) is De reference operator which means “point to” the variable whose reference they store. it requires a reference. so here i mean in SQL we refer a<br />
And Count() is behaves like a function it requires 1 argument.<br />
For ex: select count(0) in place of count(*) it returns a value.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: praveenT</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-141808</link>
		<dc:creator><![CDATA[praveenT]]></dc:creator>
		<pubDate>Sat, 18 Jun 2011 05:49:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-141808</guid>
		<description><![CDATA[In My view,
According to C++ &#039;*&#039;(asterick) is De reference operator which means &quot;point to&quot;  the variable whose reference they store. it requires a reference. so here i mean in SQL we refer a 
And Count() is behaves like a function it requires 1 argument. 
For ex: select count(0) in place of count(*) it returns a value.]]></description>
		<content:encoded><![CDATA[<p>In My view,<br />
According to C++ &#8216;*&#8217;(asterick) is De reference operator which means &#8220;point to&#8221;  the variable whose reference they store. it requires a reference. so here i mean in SQL we refer a<br />
And Count() is behaves like a function it requires 1 argument.<br />
For ex: select count(0) in place of count(*) it returns a value.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Solution &#8211; Puzzle &#8211; SELECT * vs SELECT COUNT(*) &#171; Journey to SQLAuthority</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-140978</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Solution &#8211; Puzzle &#8211; SELECT * vs SELECT COUNT(*) &#171; Journey to SQLAuthority]]></dc:creator>
		<pubDate>Wed, 15 Jun 2011 01:33:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-140978</guid>
		<description><![CDATA[[...] Earlier I have published Puzzle Why SELECT * throws an error but SELECT COUNT(*) does not. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Earlier I have published Puzzle Why SELECT * throws an error but SELECT COUNT(*) does not. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER – Solution – Puzzle – SELECT * vs SELECT COUNT(*) Journey to SQLAuthority</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-140977</link>
		<dc:creator><![CDATA[SQL SERVER – Solution – Puzzle – SELECT * vs SELECT COUNT(*) Journey to SQLAuthority]]></dc:creator>
		<pubDate>Wed, 15 Jun 2011 01:32:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-140977</guid>
		<description><![CDATA[[...] RGarvao [...]]]></description>
		<content:encoded><![CDATA[<p>[...] RGarvao [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dips</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-140841</link>
		<dc:creator><![CDATA[dips]]></dc:creator>
		<pubDate>Tue, 14 Jun 2011 07:09:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-140841</guid>
		<description><![CDATA[When you say &quot;SELECT *&quot; you are writing a partial command: &quot;SELECT these fields&quot; without saving where they should come from. &quot;*&quot; is a wildcard which expands to &quot;all fields&quot; so you need to specify the table to read from.

When you say &quot;SELECT COUNT(*)&quot; you are a different command: a SELECT that returns a single item, the COUNT, of the number of items. Because there is no list, the result comes out at 1 - the count itself.]]></description>
		<content:encoded><![CDATA[<p>When you say &#8220;SELECT *&#8221; you are writing a partial command: &#8220;SELECT these fields&#8221; without saving where they should come from. &#8220;*&#8221; is a wildcard which expands to &#8220;all fields&#8221; so you need to specify the table to read from.</p>
<p>When you say &#8220;SELECT COUNT(*)&#8221; you are a different command: a SELECT that returns a single item, the COUNT, of the number of items. Because there is no list, the result comes out at 1 &#8211; the count itself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jaymin Soneji</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-140824</link>
		<dc:creator><![CDATA[Jaymin Soneji]]></dc:creator>
		<pubDate>Tue, 14 Jun 2011 04:09:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-140824</guid>
		<description><![CDATA[Answer is very simple.

as when you are trying to Execute &quot;Select *&quot;, you must specify table name in from Clause. because * awaits for Table to give outputs of Columns and Data. when you are trying to execute Select *, this * means what ?

You have to specify query or Table to take output. so you will get an error when you will try to execute only &quot;Select * &quot;

now, the 2nd question is for : Select Count(*), it suppose to give you Count of Rows, it means if you try to Execute Select Count(1) or Select Count(*) or Select Count(Any Variable). then the output will be 1. same for all queries.]]></description>
		<content:encoded><![CDATA[<p>Answer is very simple.</p>
<p>as when you are trying to Execute &#8220;Select *&#8221;, you must specify table name in from Clause. because * awaits for Table to give outputs of Columns and Data. when you are trying to execute Select *, this * means what ?</p>
<p>You have to specify query or Table to take output. so you will get an error when you will try to execute only &#8220;Select * &#8221;</p>
<p>now, the 2nd question is for : Select Count(*), it suppose to give you Count of Rows, it means if you try to Execute Select Count(1) or Select Count(*) or Select Count(Any Variable). then the output will be 1. same for all queries.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sachin Nandanwar</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-140578</link>
		<dc:creator><![CDATA[Sachin Nandanwar]]></dc:creator>
		<pubDate>Sun, 12 Jun 2011 16:22:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-140578</guid>
		<description><![CDATA[Any aggregate function expects a constant or a column name as an expression.
DO NOT be confused with  *  in an aggregate function.The aggregate function does not treat it as a column name or a set of column names but a constant value, as * is a key word in SQL.

You can replace any value instead of * for the COUNT function.Ex 

Select COUNT(5) will result as 1.

The error resulting from select * is obvious it expects an object where it can extract the result set.]]></description>
		<content:encoded><![CDATA[<p>Any aggregate function expects a constant or a column name as an expression.<br />
DO NOT be confused with  *  in an aggregate function.The aggregate function does not treat it as a column name or a set of column names but a constant value, as * is a key word in SQL.</p>
<p>You can replace any value instead of * for the COUNT function.Ex </p>
<p>Select COUNT(5) will result as 1.</p>
<p>The error resulting from select * is obvious it expects an object where it can extract the result set.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Zimmerman</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-140300</link>
		<dc:creator><![CDATA[Dan Zimmerman]]></dc:creator>
		<pubDate>Fri, 10 Jun 2011 18:16:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-140300</guid>
		<description><![CDATA[here&#039;s a simple view...

the select * command returns all columns from all rows in the table.  

if any data value in any row and/or column is corrupt or has a problem an error can be returned.  

there is also a higher probability of a hardware problem from returning all the data from the table as select * does.

the select count(*) command only returns the count of rows in the table.  

as the select count(*) command does not return any actual data from the table, data corruption will likely not impact the select (*) command.

have a nice weekend  :-)]]></description>
		<content:encoded><![CDATA[<p>here&#8217;s a simple view&#8230;</p>
<p>the select * command returns all columns from all rows in the table.  </p>
<p>if any data value in any row and/or column is corrupt or has a problem an error can be returned.  </p>
<p>there is also a higher probability of a hardware problem from returning all the data from the table as select * does.</p>
<p>the select count(*) command only returns the count of rows in the table.  </p>
<p>as the select count(*) command does not return any actual data from the table, data corruption will likely not impact the select (*) command.</p>
<p>have a nice weekend  :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramesh</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-139681</link>
		<dc:creator><![CDATA[Ramesh]]></dc:creator>
		<pubDate>Wed, 08 Jun 2011 10:35:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-139681</guid>
		<description><![CDATA[Hi Friends,
Count is an aggregate function and it expects the rows (list of records) for a specified single column or whole rows for *.

So, when we use &#039;select *&#039; it definitely give and error because &#039;*&#039; is meant to have all the fields but there is not any table and without table it can only raise an error.

So, in the case of &#039;Select Count(*)&#039;, there will be an error as a record in the count function so you will get the result as &#039;1&#039;.

Try using : Select COUNT(&#039;RAMESH&#039;) and think there is an error &#039;Must specify table to select from.&#039; in place of &#039;RAMESH&#039;

Pinal : If i am wrong then please clarify this.

Thanks,
Ramesh Vagh,
Software Engineer]]></description>
		<content:encoded><![CDATA[<p>Hi Friends,<br />
Count is an aggregate function and it expects the rows (list of records) for a specified single column or whole rows for *.</p>
<p>So, when we use &#8216;select *&#8217; it definitely give and error because &#8216;*&#8217; is meant to have all the fields but there is not any table and without table it can only raise an error.</p>
<p>So, in the case of &#8216;Select Count(*)&#8217;, there will be an error as a record in the count function so you will get the result as &#8217;1&#8242;.</p>
<p>Try using : Select COUNT(&#8216;RAMESH&#8217;) and think there is an error &#8216;Must specify table to select from.&#8217; in place of &#8216;RAMESH&#8217;</p>
<p>Pinal : If i am wrong then please clarify this.</p>
<p>Thanks,<br />
Ramesh Vagh,<br />
Software Engineer</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Essaghir</title>
		<link>http://blog.sqlauthority.com/2011/05/30/sql-server-puzzle-select-vs-select-count/#comment-139670</link>
		<dc:creator><![CDATA[Essaghir]]></dc:creator>
		<pubDate>Wed, 08 Jun 2011 08:49:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13050#comment-139670</guid>
		<description><![CDATA[Hey, pinal, save us time and give the answer :)]]></description>
		<content:encoded><![CDATA[<p>Hey, pinal, save us time and give the answer :)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
