March 25, 2008 at 3:52 pm
I have tables with identical structure and unique data on various servers and use a union to consolidate them into a single viewable result. I want to join one union to another to compare data migrating from one year to the next.
Is this doable?
Thanks..
March 25, 2008 at 4:20 pm
Yes, use derived tables. It's hard to give you a good example without knowing more of your situation. If you need more help, post more info. on your DDL, sample data, etc.
http://www.sqlservercentral.com/articles/Best+Practices/61537/
SELECT *
FROM (
SELECT Col1, Col2
FROM TableA
UNION
SELECT Col1, Col2
FROM TableB
) t1
INNER JOIN (
SELECT Col1, Col2
FROM Table1
UNION
SELECT Col1, Col2
FROM Table2
) t2
ON t1.COl1 = t2.Col1
March 26, 2008 at 12:49 pm
you will need to setup a linked server between all these different sql server instances otherwise server a won't see the tables on server B
but linked server queries perform horribly... 🙂
March 26, 2008 at 12:57 pm
Ah, I did not see that your tables are not on the same server. Yes, you'll need linked servers and you'll need to watch performance.
March 27, 2008 at 9:47 am
Thanks all.. I'll give it a try.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply