Sites where a user doesn't have an account on


Please login or register to vote for this query.

(click on this box to dismiss)

Drupal Answers

Q&A for Drupal developers and administrators

-- 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 #accounts (databasename nvarchar(250), id int, displayname nvarchar(40));
create table #databases (databasename nvarchar(250));

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 #accounts 
    select ''' + @db_c_name + ''', id, displayname
      from users
      where accountid = ' + CAST(##AccountId## as nvarchar) + ';
    insert into #databases select ''' + @db_c_name + '''';
    exec (@sql)
    fetch next from db_c into @db_c_name
close db_c;
deallocate db_c;

select d.databasename,, a.displayname
  from #databases as d left outer join #accounts as a
    on d.databasename = a.databasename
  where d.databasename not like '%.Meta'
  order by;

Enter Parameters

Switch to meta site
loading Hold tight while we fetch your results