Eprs_Admin
asked on
SQL join two tables
Hi Experts,
I have two tables in SQL on two different machines.
Is it possible to join this table into one ?
I have two tables in SQL on two different machines.
Is it possible to join this table into one ?
Yes. You can do it by creating a Linked Server or using the OPENROWSET function to retrieve the data from the remote server.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Following Vitor Montalvao and Jason clark's comments:
Use linkedserver method: exec addlinkedserver to connect the two databases.
then use this example that works for me:
Use linkedserver method: exec addlinkedserver to connect the two databases.
then use this example that works for me:
with
table1query as
(
select col1 as col1,col2 as col2 from [server].[database].[dboschema].[tablename]
)
,
tabl2query as
(
select col1 as col1,col2 as col2 from [otherserver].[otherdatabase].[otherdboschema].[othertablename]
)
select * from table1query
union all
select * from table2query