Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Finding no. of Rows in all tables of a datbase in one line of script Expand / Collapse
Author
Message
Posted Tuesday, January 11, 2011 12:23 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, August 28, 2014 2:56 PM
Points: 106, Visits: 367
In my experience, every table has a row in sys.sysindexes that can be used to tell the number of rows in the table.

SELECT i.rowcnt, o.name 
FROM sys.sysobjects o JOIN sys.sysindexes i ON i.id = o.id
WHERE o.xtype = 'U' AND i.indid IN (0, 1)
ORDER BY o.name

Because these values are stored in the system tables, this is not an expensive query.
Post #1046080
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse