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 2005 Forums
 SQL Server Administration (2005)
 Record count of table is 12M and counting

Author  Topic 

jonasalbert20
Constraint Violating Yak Guru

300 Posts

Posted - 2012-09-09 : 03:18:40
I have a table where the actual count is only 77631. However when I execute a simple select statement for that table, it reaches millions and counting. It seems so strange. Have anyone encountered same issue before?

Any help is highly appreciated. thanks in advance.

For fast result follow this...
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

Want Philippines to become 1st World COuntry? Go for World War 3...

chadmat
The Chadinator

1974 Posts

Posted - 2012-09-09 : 04:15:02
Show us the select

-Chad
Go to Top of Page

jonasalbert20
Constraint Violating Yak Guru

300 Posts

Posted - 2012-09-09 : 04:22:57
Its only "select * from slip_sales". Only one table. From Getting row count of table in SQL Server 2005 (http://dimantdatabasesolutions.blogspot.com/2008/05/getting-row-count-of-table-in-sql.html), the actual count of that table is 70K+ only. However, when I use the select statement it reaches 12M+. I restore the database on my laptop just to make sure that there are no other running applications.

For fast result follow this...
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

Want Philippines to become 1st World COuntry? Go for World War 3...
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2012-09-09 : 04:29:42
Do:

SELECT Count(*)
FROM Slip_Sales

-Chad
Go to Top of Page

jonasalbert20
Constraint Violating Yak Guru

300 Posts

Posted - 2012-09-09 : 04:35:49
tnx for the reply chad. I already tried that one. However, I could not get the count using that statement. I took a lunch and when I come back after an hour, I still don't have the count. hmmm, Maybe the table is corrupted?

For fast result follow this...
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

Want Philippines to become 1st World COuntry? Go for World War 3...
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2012-09-09 : 04:36:48
Run a DBCC Checktable

(Or DBCC Checkdb)

-Chad
Go to Top of Page

jonasalbert20
Constraint Violating Yak Guru

300 Posts

Posted - 2012-09-09 : 04:37:04
My issue is, how come that table reaches 12M and the actual count is 70K? tnx


For fast result follow this...
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

Want Philippines to become 1st World COuntry? Go for World War 3...
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2012-09-09 : 04:38:14
Corruption is the only thing that makes any sense.

-Chad
Go to Top of Page

jonasalbert20
Constraint Violating Yak Guru

300 Posts

Posted - 2012-09-09 : 06:09:24
yup! it is corrupted. tnx...

For fast result follow this...
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

Want Philippines to become 1st World COuntry? Go for World War 3...
Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2012-09-10 : 10:02:32
Total number of rows can be extracted using following query.

SELECT OBJECT_NAME(OBJECT_ID), sys.partitions.rows
FROM sys.partitions
WHERE index_id = 1
AND object_id = OBJECT_ID('Slip_Sales')

--------------------------
http://connectsql.blogspot.com/
Go to Top of Page
   

- Advertisement -