Can SEDE be used to compare SE sites?


Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

select name
from sys.databases

select sot.tagname 
from tags sot 
inner join superuser.dbo.tags sut 
        on sut.tagname = sot.tagname
inner join serverfault.dbo.tags sft
        on sft.tagname = sot.tagname

-- all databases
declare  db_c cursor for select [name] 
                         from sys.databases 
                         where database_id > 5 -- skip master, temp, model, msdb, Data.SE

declare @db_c_name sysname   -- holds name of db after fetch
declare @sql nvarchar(max) -- holds build up sql string

-- result table
create table #all_users ( site nvarchar(250)
                            , cnt int
open db_c
fetch next from db_c into @db_c_name
while(@@FETCH_STATUS = 0)
    set @sql = N'use '+ QUOTENAME(@db_c_name) +';
    insert into #all_users 
    select '''+ QUOTENAME(@db_c_name) +''', count(*) from users';
    exec (@sql)
   fetch next from db_c into @db_c_name
close db_c;
deallocate db_c;

select * from #all_users

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results