Pankaj Pathak
List out 3 ways to get an accurate count of the number of records in a table?
By Pankaj Pathak in SQL Server on May 05 2013
  • Rakesh Singh
    Apr, 2014 2

    1. select COUNT(1) from Table 2. select COUNT(*) from Table 3. select * from Table4.select SUM (row_count) FROM sys.dm_db_partition_stats WHERE object_id=OBJECT_ID('table') AND (index_id=0 or index_id=1);5.SELECT rows FROM sysindexes WHERE id = OBJECT_ID('Table') AND indid < 26. SELECT CAST(p.rows AS float) FROM sys.tables AS tbl INNER JOIN sys.indexes AS idx ON idx.object_id = tbl.object_id and idx.index_id < 2 INNER JOIN sys.partitions AS p ON p.object_id=CAST(tbl.object_id AS int) AND p.index_id=idx.index_id WHERE ((tbl.name=N'Table' AND SCHEMA_NAME(tbl.schema_id)='dbo'))

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS