# Toad for SQL Server 6.7.0.176 - Problem with row count

**URL:** <https://forums.toadworld.com/t/toad-for-sql-server-6-7-0-176-problem-with-row-count/37851>\
**Category:** Toad for SQL Server\
**Created:** [June 13, 2016, 8:47am UTC](https://forums.toadworld.com/t/toad-for-sql-server-6-7-0-176-problem-with-row-count/37851 "2016-06-13T08:47:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![s.bertolotti](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@s.bertolotti](https://forums.toadworld.com/u/s.bertolotti)\
**Post date:** [June 13, 2016, 8:47am UTC](https://forums.toadworld.com/t/toad-for-sql-server-6-7-0-176-problem-with-row-count/37851/1 "2016-06-13T08:47:20Z")

</div>

I attach a screenshot for details :

 ![toad_error_count.png](https://global.discourse-cdn.com/quest/original/2X/7/7d85a6217c746d32495ebb01bd025dd8f3b8e8f8.png)

As you can see I execute a simple - select count (\*) from TABLE\_NAME.

The results show me the row counts equal to 6932.

If you see in the object Explorer, same table, row counts is equal to 6695.

What's the real value of row counts ?

From my point of view the first, 6932, but this is very strange or I never set correctly some parameters.

I stay tune for your consideration.

Best regards,

Sergio

---

<div class="post-metadata">

**Author:** ![Martin.Holkovic](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/martin.holkovic/32/318_2.png) [@Martin.Holkovic](https://forums.toadworld.com/u/Martin.Holkovic)\
**Post date:** [June 15, 2016, 12:32am UTC](https://forums.toadworld.com/t/toad-for-sql-server-6-7-0-176-problem-with-row-count/37851/2 "2016-06-15T00:32:38Z")

</div>

Hello Sergio,

Thank you for your post - we will try to reproduce the problem on our side and let you know about our findings.

-Martin

---

<div class="post-metadata">

**Author:** ![s.bertolotti](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@s.bertolotti](https://forums.toadworld.com/u/s.bertolotti)\
**Post date:** [June 15, 2016, 1:12am UTC](https://forums.toadworld.com/t/toad-for-sql-server-6-7-0-176-problem-with-row-count/37851/3 "2016-06-15T01:12:59Z")

</div>

Hello Martin,

many thank’s for your support.

For your information I use SQL Server 2012 Developer edition with service pack 3. The problem is present too if I try the same statement on a SQL Server 2012 Advanced Express Edition 2012 with service pack 3.

I never try with another version of SQL Server, for example SQL Server 2014,etc,etc,…

I hope this can be helpfull for you and I stay tune for your consideration.

Best regards,

Sergio

---

<div class="post-metadata">

**Author:** ![Martin.Holkovic](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/martin.holkovic/32/318_2.png) [@Martin.Holkovic](https://forums.toadworld.com/u/Martin.Holkovic)\
**Post date:** [June 15, 2016, 4:53am UTC](https://forums.toadworld.com/t/toad-for-sql-server-6-7-0-176-problem-with-row-count/37851/4 "2016-06-15T04:53:31Z")

</div>

Can you please confirm which row count is correct using SQL Server Management studio (hope you have it installed)? I believe running the same query will do just fine.

---

<div class="post-metadata">

**Author:** ![s.bertolotti](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@s.bertolotti](https://forums.toadworld.com/u/s.bertolotti)\
**Post date:** [June 16, 2016, 12:56pm UTC](https://forums.toadworld.com/t/toad-for-sql-server-6-7-0-176-problem-with-row-count/37851/5 "2016-06-16T12:56:30Z")

</div>

Hi Martin,

if I open Microsoft SSMS and execute the sql select count(_) from TABLE\_NAME I obtain the same result like execute the same select count(_) etc,etc, in last version of TOAD 6.7 .

Select count(\*) from TABLE\_NAME works fine both in SSMS and TOAD 6.7 .

Best regards,

Sergio

---

<div class="post-metadata">

**Author:** ![s.bertolotti](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@s.bertolotti](https://forums.toadworld.com/u/s.bertolotti)\
**Post date:** [April 24, 2017, 6:36am UTC](https://forums.toadworld.com/t/toad-for-sql-server-6-7-0-176-problem-with-row-count/37851/6 "2017-04-24T06:36:31Z")

</div>

Hi Martin,

last beta version of Toad for SQL Server Beta 6.8.0.636 (32 bit) and the problem is still present.

Have you some news about this bug ?

I stay tune for your answer,

Best regards,

Sergio

---

<div class="post-metadata">

**Author:** ![VasiliyFofanov](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/vasiliyfofanov/32/10873_2.png) [@VasiliyFofanov](https://forums.toadworld.com/u/VasiliyFofanov)\
**Post date:** [April 24, 2017, 11:06pm UTC](https://forums.toadworld.com/t/toad-for-sql-server-6-7-0-176-problem-with-row-count/37851/7 "2017-04-24T23:06:58Z")

</div>

Hi Martin,

First of all sorry for so late response.

For calculating row count Toad uses the same script for getting row count as below  
`SELECT` `sc.name` `+``'.'``+` `ta.name``TableName`  
`,``SUM``(``pa.rows``)` `RowCnt`  
`FROM` `sys.tables ta`  
`INNER JOIN` `sys.partitions pa`  
`ON` `pa.``OBJECT_ID` `=` `ta.``OBJECT_ID`  
`INNER JOIN` `sys.schemas sc`  
`ON` `ta.schema_id` `=` `sc.schema_id`  
`WHERE` `ta.is_ms_shipped` `=` `0` `AND` `pa.index_id` `IN` `(``1``,``0``)`  
`GROUP BY` `sc.name``,``ta.name`  
`ORDER BY` `SUM``(``pa.rows``)` `DESC`

It’s [common](https://blogs.msdn.microsoft.com/martijnh/2010/07/15/sql-serverhow-to-quickly-retrieve-accurate-row-count-for-table/) way to get row count for collection  
As you can see Toad uses sum by sys.partitions.rows column. If you go to[msdn](https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-partitions-transact-sql) you will see description for this table - ‘Indicates the **approximate** number of rows in this partition’  
So, unfortunately it’s approximate row count

Best regards,  
Vasiliy

---

<div class="post-metadata">

**Author:** ![s.bertolotti](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@s.bertolotti](https://forums.toadworld.com/u/s.bertolotti)\
**Post date:** [April 25, 2017, 2:05am UTC](https://forums.toadworld.com/t/toad-for-sql-server-6-7-0-176-problem-with-row-count/37851/8 "2017-04-25T02:05:28Z")

</div>

Hello Vasiliy,

many thank’s for your answer.

Now the situation is more clear.

At this point I uncheck option to show rows count in object explorer because this generate misunderstanding, and I continue to count numbers of records in the classical mode with select count(\*) on tablename.

This option is not useful for me.

Best regards,

Sergio

---

<div class="post-metadata">

**Author:** ![henrik.schuetze](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@henrik.schuetze](https://forums.toadworld.com/u/henrik.schuetze)\
**Post date:** [April 25, 2017, 2:29am UTC](https://forums.toadworld.com/t/toad-for-sql-server-6-7-0-176-problem-with-row-count/37851/9 "2017-04-25T02:29:15Z")

</div>

Hello Sergio,

but you know that select Count(\*) produce a lot of io traffic ?

This because SQL Server made a full table scan and he blocks the full table for a read scan. I think, that is not a valid way in a production Environment.

For more Information:

[https://www.brentozar.com/archive/2014/02/count-number-rows-table-sql-server/](https://www.brentozar.com/archive/2014/02/count-number-rows-table-sql-server/)

or

[https://sqlperformance.com/2014/10/t-sql-queries/bad-habits-count-the-hard-way](https://sqlperformance.com/2014/10/t-sql-queries/bad-habits-count-the-hard-way)

greetings

Henrik

---

<div class="post-metadata">

**Author:** ![s.bertolotti](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@s.bertolotti](https://forums.toadworld.com/u/s.bertolotti)\
**Post date:** [April 25, 2017, 5:03am UTC](https://forums.toadworld.com/t/toad-for-sql-server-6-7-0-176-problem-with-row-count/37851/10 "2017-04-25T05:03:36Z")

</div>

Hello Henrik,

many thank’s for your clarification.

I’m agree with you about select count(\*) from…, etc,etc,…

Usually I don’t use - select count(\*) … - statement, but last year, I’ve used it, on a small db I notice the difference and at this point I don’t understand what is the real value of number of records.

I delete all records from a table and after re-import it via import wizard. I exported about 6000 records from source and I want to have the same records number in the destination.

If I see row count property I have 6000 records, if I execute select count(\*)… I have 6150 records. At this point I don’t understand why ?

This generate the problem.

At the end of the story I disable - row count - property in object explorer and occasionally i use select count(\*) to count my records.

Many thanjk’s for your reply.

Best regards,

Sergio
