Create Table Union Between Multiple Data Sources

StackOverflow https://stackoverflow.com/questions/20894932
  •  
  •  | 
  •   ( words)
 Checked

Question

I am working in Crystal Reports 2011 and I am trying to merge two tables from two different data sources into one command to use in a report.

I am having a hard time finding any solid examples online of how to accomplish this inside of a command. I would expect to use a UNION and it look something like:

SELECT *
FROM DSN1.Employee
UNION
SELECT *
FROM DSN2.Employee

The two tables are the exact same, just in different databases that I cannot alter or add to.

Any guidance would be a tremendous help. Thank you in advance.

No correct solution

OTHER TIPS

Dont know exactly what you mean by having a hard time anyway try something like this ....

Explicitly mention the column names in both selects and use UNION ALL, use fully qualified names of your tables something like this....

SELECT Column1, Column2, Column3, ..... <Other Column Names>
FROM [Database_Name1].[Schema1].[Table_Name1]
UNION ALL
SELECT Column1, Column2, Column3, ..... <Other Column Names>
FROM [Database_Name2].[Schema1].[Table_Name2]

using this syntax eliminates most of the possible errors.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow