Reputation: 1197
I have two tables - table1 and table2 - with the same columns in two different schema.
Table1
col1 | col2 | col3
-----+------+------
a1 | b1 | c1
a2 | b2 | c2
and table2
col1 | col2 | col3
-----+------+------
a1 | b1 | c1
a2 | b2 | c2
How to query from both tables (schema1.table1
and schema2.table2
) so that I get the result as:
col1 | col2 | col3
-----+------+------
a1 | b1 | c1
a2 | b2 | c2
a1 | b1 | c1
a2 | b2 | c2
Upvotes: 2
Views: 1408
Reputation: 1
You can use the union operator.
More details regarding the union operator can be found at https://www.w3schools.com/sql/sql_union.asp
Upvotes: -1
Reputation: 775
Just use union all and get the data from those two tables
SELECT col1, col2, col3 FROM schema1.dbo.table1
UNION ALL
SELECT col1, col2, col3 FROM schema2.dbo.table2
Upvotes: 1
Reputation:
This looks like a simple union
select col1, col2, col3
from schema_1.table1
union all
select col1, col2, col3
from schema_2.table2
Upvotes: 1