Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 How do i get row count - LOL

Author  Topic 

clarkbaker1964
Constraint Violating Yak Guru

428 Posts

Posted - 2008-12-17 : 20:28:19
SQL 2000 -

I have this table which I don't know how many rows it contains but i need to get a fairly accurate count.

However the number of rows is currently = max size of int field (2,147,483,647).

I am getting the same number recorded in the sysindexes rows field.

exec SP_SPACEUSED 'EventsStrings'
name EventsStrings
rows 2,147,483,647
reserved 529107688 KB
data 525888616 KB
index_size 3219136 KB
unused -64 KB

Please help



You can do anything at www.zombo.com

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-12-17 : 20:33:02
Why can't you run COUNT(*)?

If you need it to be fairly accurate and you don't want to use COUNT(*), then you'll need to run DBCC UPDATEUSAGE or @updateusage = true for sp_spaceused.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

clarkbaker1964
Constraint Violating Yak Guru

428 Posts

Posted - 2008-12-17 : 21:14:26
Im running count(*) right now but this returns int so im not sure how the function will react when it overflows the max int value.

sp_spaceused looks like it is returning the max int value, have you tried this on a table this size?

You can do anything at www.zombo.com
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-12-17 : 22:33:04
Then you need to use COUNT_BIG(*) or see properties of table.
Go to Top of Page

clarkbaker1964
Constraint Violating Yak Guru

428 Posts

Posted - 2008-12-17 : 23:55:23
SAME RESULT:
DBCC UPDATEUSAGE(InTrust_Audit_DB2,EventsStrings)
exec SP_SPACEUSED 'EventsStrings'
name rows reserved data index_size unused
EventsStrings 2147483647 529191352 KB 525906408 KB 3219232 KB 65712 KB

select count(*) from dbo.EventsStrings with (nolock)
Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type int

Trying COUNT_BIG I completely forgot about that function! Excellent Sodeep!

<edited out flame>

You can do anything at www.zombo.com
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-12-18 : 08:43:45
quote:
Originally posted by clarkbaker1964


Trying COUNT_BIG I completely forgot about that function! Excellent Sodeep!




Good!! Count_big(*) returns Bigint value so you can go from -2^63 to 2^63-1.
Go to Top of Page
   

- Advertisement -