Du skal bruge dynamisk sql:
declare @numrows int = (select count(*) from sys.servers)
declare @i int = 1
declare @Sql(1000)
declare @servername varchar(max)
while @i <= @numrows
BEGIN
select @servername = servernaam
from #servers where rij = @i
set @Sql = 'select * from '[email protected]+'.DATABASE.DBO.TABLE'
exec(@Sql)
set @i = @i+1
END
Her er mere information om exec.