how to find out how many total records in DB???

  • What is the quickest way to find out through query analyzer?

     

    -total number of records in table?

    -total number of  records in a db

     

    I can count total tables in a db:

    select count(*) from   sysobjects

    where type = 'U'

    and      name <> 'dtproperties'

  • If all your tables have a clustered index then

    SELECT object_name(id),SUM(rows)

    FROM sysindexes

    WHERE indid=1

    GROUP BY object_name(id)

    WITH ROLLUP

    indid=1 is the clustered index

  • Hi,

     

    Total no of records in a table

    select count(*) from tablename

     

    Total number of records in a database

    For userdefined table

    SELECT

        [TableName] = so.name,

    [Table id]=so.id,

        [RowCount] = MAX(si.rows)

    into #Temp1 FROM

        sysobjects so,  sysindexes si

    WHERE

        so.xtype = 'U'

        AND   si.id = OBJECT_ID(so.name)

    GROUP BY

        so.name,so.id

    ORDER BY

        3 DESC

    select sum([rowcount]) from #temp1

    drop table #temp1

    HTH

    from

    Killer

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply