<?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/"
		>
<channel>
	<title>Comments on: SQL Server &#8211; COUNT(expression) bug</title>
	<atom:link href="http://www.ssistalk.com/2009/07/24/sql-server-countexpression-bug/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ssistalk.com/2009/07/24/sql-server-countexpression-bug/</link>
	<description>Random thoughts and experiences with SSIS, by Phil Brammer</description>
	<lastBuildDate>Wed, 25 Jan 2012 10:27:44 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: shanghai escort girl</title>
		<link>http://www.ssistalk.com/2009/07/24/sql-server-countexpression-bug/comment-page-1/#comment-31076</link>
		<dc:creator>shanghai escort girl</dc:creator>
		<pubDate>Tue, 09 Aug 2011 07:19:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.ssistalk.com/?p=146#comment-31076</guid>
		<description>Attractive section of content. I just stumbled upon your site and in accession capital to assert that I get in fact enjoyed account your blog posts. Any way I will be subscribing to your augment and even I achievement you access consistently quickly.</description>
		<content:encoded><![CDATA[<p>Attractive section of content. I just stumbled upon your site and in accession capital to assert that I get in fact enjoyed account your blog posts. Any way I will be subscribing to your augment and even I achievement you access consistently quickly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vigrx plus result</title>
		<link>http://www.ssistalk.com/2009/07/24/sql-server-countexpression-bug/comment-page-1/#comment-22013</link>
		<dc:creator>vigrx plus result</dc:creator>
		<pubDate>Wed, 11 May 2011 16:15:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.ssistalk.com/?p=146#comment-22013</guid>
		<description>thanks to the bloggers for sharing true information that is useful and beneficial to readers and other fellow bloggers.</description>
		<content:encoded><![CDATA[<p>thanks to the bloggers for sharing true information that is useful and beneficial to readers and other fellow bloggers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Power Balance pas cher</title>
		<link>http://www.ssistalk.com/2009/07/24/sql-server-countexpression-bug/comment-page-1/#comment-8167</link>
		<dc:creator>Power Balance pas cher</dc:creator>
		<pubDate>Mon, 11 Oct 2010 21:18:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.ssistalk.com/?p=146#comment-8167</guid>
		<description>Hi I love this forumI&#039;m also passionated in extreme sport and strategies to be a lot more efficient...I discovered a piece technology that make me more efficientThanks again for your forumBye &lt;a href=&quot;http://powerbalancepascher.blogspot.com/&quot; rel=&quot;nofollow&quot;&gt;power balance pas cher&lt;/a&gt; &lt;a href=&quot;http://powerbalancediscount.blogspot.com/&quot; rel=&quot;nofollow&quot;&gt;power balance discount&lt;/a&gt; &lt;a href=&quot;http://cheappowerbalance.blogspot.com/&quot; rel=&quot;nofollow&quot;&gt;cheap powerbalance&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Hi I love this forumI&#8217;m also passionated in extreme sport and strategies to be a lot more efficient&#8230;I discovered a piece technology that make me more efficientThanks again for your forumBye <a href="http://powerbalancepascher.blogspot.com/" rel="nofollow">power balance pas cher</a> <a href="http://powerbalancediscount.blogspot.com/" rel="nofollow">power balance discount</a> <a href="http://cheappowerbalance.blogspot.com/" rel="nofollow">cheap powerbalance</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil Brammer</title>
		<link>http://www.ssistalk.com/2009/07/24/sql-server-countexpression-bug/comment-page-1/#comment-1736</link>
		<dc:creator>Phil Brammer</dc:creator>
		<pubDate>Mon, 03 Aug 2009 11:26:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.ssistalk.com/?p=146#comment-1736</guid>
		<description>Olly,
x.column_id is correct.  Because we are left joining to the subquery aliased as &#039;x,&#039; I wanted to show that its value is indeed NULL.  If I chose c.column_id instead, we would actually see some values in that column, which is not the intended behavior.

Phil</description>
		<content:encoded><![CDATA[<p>Olly,<br />
x.column_id is correct.  Because we are left joining to the subquery aliased as &#8216;x,&#8217; I wanted to show that its value is indeed NULL.  If I chose c.column_id instead, we would actually see some values in that column, which is not the intended behavior.</p>
<p>Phil</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olly A</title>
		<link>http://www.ssistalk.com/2009/07/24/sql-server-countexpression-bug/comment-page-1/#comment-1735</link>
		<dc:creator>Olly A</dc:creator>
		<pubDate>Mon, 03 Aug 2009 10:11:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.ssistalk.com/?p=146#comment-1735</guid>
		<description>Wow!  That&#039;s really one to look out for.  I do think that one of your column headings in the sample data is wrong, though.  Shouldn&#039;t &#039;x.column_id&#039; read &#039;c.column_id&#039;?  Had me scratching my head for a few minutes!

Thanks for alerting us to this - could save a lot of confusion!

Olly</description>
		<content:encoded><![CDATA[<p>Wow!  That&#8217;s really one to look out for.  I do think that one of your column headings in the sample data is wrong, though.  Shouldn&#8217;t &#8216;x.column_id&#8217; read &#8216;c.column_id&#8217;?  Had me scratching my head for a few minutes!</p>
<p>Thanks for alerting us to this &#8211; could save a lot of confusion!</p>
<p>Olly</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil Brammer</title>
		<link>http://www.ssistalk.com/2009/07/24/sql-server-countexpression-bug/comment-page-1/#comment-1732</link>
		<dc:creator>Phil Brammer</dc:creator>
		<pubDate>Sun, 02 Aug 2009 02:36:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.ssistalk.com/?p=146#comment-1732</guid>
		<description>Ed, while you are correct, I think you may be misinterpreting what I&#039;ve written.

The bug as I&#039;ve indicated above, is where COUNT(column) (which only returns a count of NON NULL values) actually returns a value when in reality it should not.  If you look at the last resultset I&#039;ve provided, the last column indicates where this bug is present (the cnt_returns_1_y_n column).  Clearly you can see that COUNT is returning a 1 where the column it is counting is NULL.  THAT is a bug.

Phil</description>
		<content:encoded><![CDATA[<p>Ed, while you are correct, I think you may be misinterpreting what I&#8217;ve written.</p>
<p>The bug as I&#8217;ve indicated above, is where COUNT(column) (which only returns a count of NON NULL values) actually returns a value when in reality it should not.  If you look at the last resultset I&#8217;ve provided, the last column indicates where this bug is present (the cnt_returns_1_y_n column).  Clearly you can see that COUNT is returning a 1 where the column it is counting is NULL.  THAT is a bug.</p>
<p>Phil</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ed</title>
		<link>http://www.ssistalk.com/2009/07/24/sql-server-countexpression-bug/comment-page-1/#comment-1731</link>
		<dc:creator>Ed</dc:creator>
		<pubDate>Sun, 02 Aug 2009 02:29:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.ssistalk.com/?p=146#comment-1731</guid>
		<description>Actually, from what I&#039;ve been taught in my CURRENT SQL classes (70-441 and 70-442) this is a documented FEATURE, NOT a bug.

It clearly states in the SQL class that I am taking that if WILL NOT get a count of all the records in a table IF YOU DO A COUNT ON A FIELD THAT HAS NULLS BECAUSE A NULL IS JUST THAT - NULL.

As such, the code you listed does exactly what you told it to do - get a count on the field FirstName field WHERE IT HAS A VALUE.  NULL doesn&#039;t &#039;count&#039; (forgive the pun) in this case.

For your count to be accurate simply select a field defined as NOT NULL, like the primary key of your data record.</description>
		<content:encoded><![CDATA[<p>Actually, from what I&#8217;ve been taught in my CURRENT SQL classes (70-441 and 70-442) this is a documented FEATURE, NOT a bug.</p>
<p>It clearly states in the SQL class that I am taking that if WILL NOT get a count of all the records in a table IF YOU DO A COUNT ON A FIELD THAT HAS NULLS BECAUSE A NULL IS JUST THAT &#8211; NULL.</p>
<p>As such, the code you listed does exactly what you told it to do &#8211; get a count on the field FirstName field WHERE IT HAS A VALUE.  NULL doesn&#8217;t &#8216;count&#8217; (forgive the pun) in this case.</p>
<p>For your count to be accurate simply select a field defined as NOT NULL, like the primary key of your data record.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

