Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Query many databases at the same time

$
0
0

Hi,

I have 44 identical databases and need to query them all at the same time and calculate an average of two columns. I have only read access to the databases so I cannot create any objects in the database. I've tested a query using INNER JOINs but it's very slow when querying all the databases in one query.  (My example code here only contain 2 databases.)

SELECT TOP 1 t1.tstamp, (t1.fld01 + t2.fld01)/2 AS 'fld1', (t1.fld02 + t2.fld02)/2 AS 'fld2' FROM [DB1].[dbo].[T1] AS t1 INNER JOIN [DB2].[dbo].[T1] AS t2 ON t1.tstamp = t2.tstamp ORDER BY t1.tstamp DESC

What would be a good solution to this? Any suggestions would be appreciated.

Thanks,
Frode Magnussen


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>