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.
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 EventsStringsrows 2,147,483,647reserved 529107688 KBdata 525888616 KBindex_size 3219136 KBunused -64 KBPlease helpYou can do anything at www.zombo.com |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
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 |
|
|
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. |
|
|
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 unusedEventsStrings 2147483647 529191352 KB 525906408 KB 3219232 KB 65712 KBselect count(*) from dbo.EventsStrings with (nolock)Msg 8115, Level 16, State 2, Line 1Arithmetic overflow error converting expression to data type intTrying COUNT_BIG I completely forgot about that function! Excellent Sodeep!<edited out flame>You can do anything at www.zombo.com |
|
|
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. |
|
|
|
|
|
|
|