Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Can you count columns from sys.partition table, if not is select count(1) the fastest way ?

$
0
0
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

Viewing all articles
Browse latest Browse all 3145

Latest Images

Trending Articles



Latest Images