Can you count columns from a variation of the following query ? set statistics time onSELECTOBJECT_SCHEMA_NAME(object_id) as dbo,OBJECT_NAME(object_id) as rows,SUM(Rows) AS NumOfRows --sum the rows if there are multiple partitionsFROMsys.partitionsWHEREindex_id < 2 --ignore the partitions from non-clustered indexes if anyand OBJECT_NAME(object_id) = 'table'GROUP BYOBJECT_IDORDER BYNumOfRows DESCIf not, is the next query the fastest way?set statistics time onSELECT COUNT(1) cnt, company FROM tablegroup by companyorder by cnt descThanks
↧