none
Determine number of rows in a table

Answers

  • One way to return the number of rows is to simply perform a count on a column in a table.

    Select Count(column_name) from table_name
    Thursday, January 7, 2010 7:53 PM
  • You can use
    1.select count(*) from the tablename

    2.USE dbname
    go
    SELECT object_id,row_count FROM sys.dm_db_partition_stats
    WHERE object_id =  OBJECT_ID('tablename');
    GO


    Thanks, Leks
    Thursday, January 7, 2010 8:15 PM
  • select @@ROWCOUNT But priorly you should execute the query preferably used is Proc ! 

    Sys .sysindexes will also do the trick just modify the query that lekss provided 

    SELECT id,rows FROM sys.sysindexes 
    WHERE id =  OBJECT_ID('tablename')

    ---------------------
    Thanks,Suhas V
    Thursday, January 7, 2010 9:28 PM

All replies

  • One way to return the number of rows is to simply perform a count on a column in a table.

    Select Count(column_name) from table_name
    Thursday, January 7, 2010 7:53 PM
  • You can use
    1.select count(*) from the tablename

    2.USE dbname
    go
    SELECT object_id,row_count FROM sys.dm_db_partition_stats
    WHERE object_id =  OBJECT_ID('tablename');
    GO


    Thanks, Leks
    Thursday, January 7, 2010 8:15 PM
  • select @@ROWCOUNT But priorly you should execute the query preferably used is Proc ! 

    Sys .sysindexes will also do the trick just modify the query that lekss provided 

    SELECT id,rows FROM sys.sysindexes 
    WHERE id =  OBJECT_ID('tablename')

    ---------------------
    Thanks,Suhas V
    Thursday, January 7, 2010 9:28 PM
  • Thank you - I'm going to look at this ASAP.
    Friday, January 8, 2010 8:46 PM