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 (site nvarchar(250), id int, displayname nvarchar(40));

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);
    exec (@sql)
   fetch next from db_c into @db_c_name
close db_c;
deallocate db_c;

select * from #accounts;

Enter Parameters

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