Wenn die Datenbanken auf einem Server sind, dann versuch doch mal das hier
SQL-Code:
declare @TableName
varchar(80) = '
Analysis'
declare @dbName
varchar(80)
declare x
cursor for select name
from sysdatabases
open x
declare @
sql varchar(255)
declare @sqlcmd
varchar (255)
set @sqlcmd = '
if exists(select 1 from [$1].sys.tables where name = ''
$2''
) '
set @sqlcmd=@sqlcmd + '
exec(''
select ''
''
$1''
''
as [Database], count(*) as Cnt from [$1]..[$2]''
)'
declare @result
int
fetch next
from x
into @dbname
while (@@FETCH_STATUS=0)
begin
set @
sql = replace (@sqlcmd,'
$1',@dbname)
set @
sql = replace (@
sql ,'
$2',@TableName)
exec( @
sql)
fetch next
from x
into @dbname
end
close x
deallocate x