Re: Records in a database

From: Dan Guzman (guzmanda_at_nospam-online.sbcglobal.net)
Date: 12/04/04


Date: Fri, 3 Dec 2004 21:17:26 -0600

Expanding on Wayne's response, you can get an estimated rowcount from
sysindexes using the query below. You can execute sp_spaceused
@updateusage=true beforehand to improve accuracy.

SELECT SUM(rows)
FROM sysindexes
WHERE
    indid IN(0, 1) AND
    OBJECTPROPERTY(id, 'IsMSShipped') = 0

-- 
Hope this helps.
Dan Guzman
SQL Server MVP
"robert_at_cbb" <robertatcbb@discussions.microsoft.com> wrote in message 
news:55495ECE-2FC4-4C9C-BDBA-EE76A73E6639@microsoft.com...
> Thanks guys, how would I colloct the record count of the database.
>
> "Wayne Snyder" wrote:
>
>> For a quick (estimated ) rowcount, sp_spaceused tablename,,, This data is
>> stored in Sysindexes, in case you wish to write your own query.
>>
>> -- 
>> Wayne Snyder, MCDBA, SQL Server MVP
>> Mariner, Charlotte, NC
>> www.mariner-usa.com
>> (Please respond only to the newsgroups.)
>>
>> I support the Professional Association of SQL Server (PASS) and it's
>> community of SQL Server professionals.
>> www.sqlpass.org
>>
>> "robert_at_cbb" <robertatcbb@discussions.microsoft.com> wrote in message
>> news:5DA210D7-62ED-4209-A7AB-8A3D828B228F@microsoft.com...
>> > I need some help. How can I find how many records are in a data base.
>>
>>
>> 


Relevant Pages

  • Re: Upgrading old query 7 to 2005.
    ... To Defrag the index at the moment we use a query that among many other ... Trying to upgrade that query so it wont use the sysindexes therefore ... Books Online has the details. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (comp.databases.ms-sqlserver)
  • Re: Record count in all tables
    ... > There a stored procedure or query that will count all the records ... > select object_name, rows from sysindexes where indid in ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: *_WA_Sys_* indexes in SysIndexes
    ... indid BETWEEN 1 AND 254 AND ... > In a solution I am currently working on, using SysIndexes. ... > files are created by SQL Server itself for optimization. ... > query, I want add a condition in "Where" clause to omit these indexes, is ...
    (microsoft.public.sqlserver.server)
  • Re: Indexes - System tables
    ... >> its making sense of the sysindexes table, ... >> That's what I get from BOL, my problem is if I create the query. ... >> I get plenty of value that's not idexes, it's not on the table thus ...
    (microsoft.public.sqlserver.programming)
  • Re: Orphan Indexes?
    ... Consider yourself lucky that you didn't work out how to delete the rows from sysindexes. ... "If it bleeds, we can fix it". ... is a bug in SQL Server, MS can probably rather quickly find a fix if you open a case... ... I have tried changing the owner of the table and then performing ...
    (microsoft.public.sqlserver.programming)

Loading