User count per site, using sede_ineachdb

0

Please login or register to vote for this query.

(click on this box to dismiss)

For a query as simple as `SELECT COUNT(*) FROM Users` ([1](https://meta.stackexchange.com/a/261955/165455), [2](https://meta.stackexchange.com/a/315533/165455)), the procedure is a simpler way to handle this, and we can also [avoid scanning tables by using `sys.partitions`](https://www.red-gate.com/simple-talk/databases/sql-server/t-sql-programming-sql-server/counting-more-efficiently/).

Genealogy and Family History Meta

Q&A about the site for expert genealogists and people interested in genealogy or family history

EXEC dbo.sede_ineachdb @SQLCommand = N'

  SELECT Site      = CONCAT([$site_url$],''|'',[$long_name$]),
         UserCount = SUM([rows])
    FROM sys.partitions
   WHERE [object_id] = OBJECT_ID(N''Users'')
     AND index_id IN (0,1);';

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results