Message
From
23/03/2010 08:01:24
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
00838308
Message ID:
01456419
Views:
72
You had a little time warp there Naomi? ;)

>Please see this link for fast row count in SQL Server
>
>http://sqlblogcasts.com/blogs/simons/archive/2010/01/14/Quickest-way-to-get-the-row-count-of-a-table.aspx
>
>>Thanks Sergey,
>>
>>thought I was going crazy!
>>
>>>>I have an SQL 2000 table that the Properties shows 1990 rows, but in the Open all it appears to have 2000 and if I use a Foxpro remote view, it shows 2000 records.
>>>>
>>>Hi Joel,
>>>
>>>There're two ways to get total records count in SQL Server table:
>>>1. SELECT COUNT(*) FROM mytable
>>>Produces correct count but may take long on tables with a lot of records.
>>>
>>>2. SELECT rowcnt FROM sysindexes WHERE id=OBJECT_ID('dbo.mytable') and indid < 2
>>>Fast but result isn't relaible because it's based on data stored in sysindexes tables which may or may not be current.
>>>
>>>Most likely SQL Server uses the second method because it's much faster on big tables.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Next
Reply
Map
View