473,387 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Very puzzling count

fn
Does anyone have possible explanations for the following results?

select count(*) from tablename
2,500,000
select count(*) from tablename where fieldname is null 2,400,000
select count(*) from tablename where fieldname is not null 900,000


Just my luck, I was showing something to the CFO when I got these
results...

I'd appreciate any hints. Thanks.

fn

Jul 20 '05 #1
5 1343
Hi

You could try DBCC CHECKDB to find any possible corruption.

John

"fn" <f_**************************@hotmail.com> wrote in message
news:Lq********************@britsys.net...
Does anyone have possible explanations for the following results?

select count(*) from tablename
>>> 2,500,000
select count(*) from tablename where fieldname is null >>> 2,400,000
select count(*) from tablename where fieldname is not null >>> 900,000


Just my luck, I was showing something to the CFO when I got these
results...

I'd appreciate any hints. Thanks.

fn

Jul 20 '05 #2
Check out MSKB 814509 to see if applies:
http://support.microsoft.com/default...09&Product=sql

As a workaround, you can set 'max degree of parallelism' to 1 or specify a
MAXDOP 1 hint.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"fn" <f_**************************@hotmail.com> wrote in message
news:Lq********************@britsys.net...
Does anyone have possible explanations for the following results?

select count(*) from tablename
>>> 2,500,000
select count(*) from tablename where fieldname is null >>> 2,400,000
select count(*) from tablename where fieldname is not null >>> 900,000


Just my luck, I was showing something to the CFO when I got these
results...

I'd appreciate any hints. Thanks.

fn

Jul 20 '05 #3
fn
Thanks for the replies.

The problem was definetely related to indexes and nulls rather than to
data curruption. I tried rebuilding the index but still got erroneous
results. On a hunch, I dropped all indexes and the query returned what
looked like correct results.

Dan, the MS article implies that the bug may not affect every
installation but doesn't provide any hints on how to test for it. Any
thoughts.

Thanks again.

FN

Dan Guzman wrote:
Check out MSKB 814509 to see if applies:
http://support.microsoft.com/default...09&Product=sql

As a workaround, you can set 'max degree of parallelism' to 1 or specify a
MAXDOP 1 hint.


Jul 20 '05 #4
> Dan, the MS article implies that the bug may not affect every
installation but doesn't provide any hints on how to test for it. Any
thoughts.
Try recreating the index in question to see if the problem reoccurs. If you
get incorrect results with the nonclustered index in place, take a look at
the query plan and then repeat with the MAXDOP 1 hint.

I suspect the bug is the culprit if you get wrong results with a parallel
query and the expected results with parallelism off. You can either use one
of the workarounds I suggested or contact PSS for the hotfix.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"fn" <f_**************************@hotmail.com> wrote in message
news:65********************@britsys.net... Thanks for the replies.

The problem was definetely related to indexes and nulls rather than to
data curruption. I tried rebuilding the index but still got erroneous
results. On a hunch, I dropped all indexes and the query returned what
looked like correct results.

Dan, the MS article implies that the bug may not affect every
installation but doesn't provide any hints on how to test for it. Any
thoughts.

Thanks again.

FN

Dan Guzman wrote:
Check out MSKB 814509 to see if applies:
http://support.microsoft.com/default...09&Product=sql
As a workaround, you can set 'max degree of parallelism' to 1 or specify a MAXDOP 1 hint.

Jul 20 '05 #5
Hi

You may want to look at the query execution plans to see which/if it is
using an index. You may also way to try

SELECT fieldname, count(*) FROM tablename GROUP BY fieldname

John

"fn" <f_**************************@hotmail.com> wrote in message
news:65********************@britsys.net...
Thanks for the replies.

The problem was definetely related to indexes and nulls rather than to
data curruption. I tried rebuilding the index but still got erroneous
results. On a hunch, I dropped all indexes and the query returned what
looked like correct results.

Dan, the MS article implies that the bug may not affect every
installation but doesn't provide any hints on how to test for it. Any
thoughts.

Thanks again.

FN

Dan Guzman wrote:
Check out MSKB 814509 to see if applies:
http://support.microsoft.com/default...09&Product=sql
As a workaround, you can set 'max degree of parallelism' to 1 or specify a MAXDOP 1 hint.

Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: andrea | last post by:
I was thinking to code the huffman algorithm and trying to compress something with it, but I've got a problem. How can I represent for example a char with only 3 bits?? I had a look to the...
0
by: Plumer | last post by:
Hello everyone, Yesterday I posted a message about implementing drag & drop in a TreeView control. I'm having real difficulty getting this to work -- the process seems to be incredibly...
1
by: John Wharmby | last post by:
Hi there, I have been stumped by a where statement! (Thought it would never happen!) I have a database that stores parts of postcodes for a survey to see where our customers have traveled...
10
by: Bernard Liang | last post by:
Consider the following excerpt below, with the included relevant declarations. Firstly, the lines marked with **, ***, **** at the beginning are not supposed to have those stars at the...
12
by: John | last post by:
I can't get my head around this! I have the following code: <% .... Code for connection to the database ... .... Code for retrieving recordset ... If Not rs.EOF Then ... Do something...
73
by: Rajeet Dalawal | last post by:
Good day group. I was asked in an interview to explain the behavior of this program. void main() { char *s = "abc"; int *i = (int *) s; printf("%x", *i); }
1
by: Chris Dunaway | last post by:
When working with GDI+, calling the CreateGraphics method to draw on a control has normally been frowned upon and it is always emphasized to dispose of pens and brushes and other GDI objects lest...
6
by: Terry Carroll | last post by:
I am trying to do something with a very large tarfile from within Python, and am running into memory constraints. The tarfile in question is a 4-gigabyte datafile from freedb.org,...
4
by: jlhsgcib | last post by:
Hello, I have the following snippet of code: sub getPasswordStatus { my ($login, $password) = @_; my$quotedLogin = quotemeta($login);
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.