>>> Programming >> MSSQL > How to join to databases together? (This page has been seen 563 times)
How to join to databases together?
Lets say you have a Database with a key from another database, lets call this
key MYID. This KEY exists in both databases ofcourse so you have something to
join them on
SELECT t1.*,t2.* from TABLE1 t1
inner join OPENDATASOURCE(
'SQLOLEDB',
'Data Source=IP;User ID=USER;Password=PASS'
).DATABASE2.dbo.TABLE2 t2 on t1.MYID = t2.MYID
SELECT t1.*,t2.* from TABLE1 t1
inner join OPENDATASOURCE(
'SQLOLEDB',
'Data Source=IP;User ID=USER;Password=PASS'
).DATABASE2.dbo.TABLE2 t2 on t1.MYID = t2.MYID
Like
Dislike
Advertisement by Google
Comment:
Code Language:
Code:
Here you can paste a code example. It will then be processed by SyntaxHighlighter and formatted for easier readability.
Please remember to select the correct Code Language in the select above so the SyntaxHighlighter can highlight the code properly.
Code:
Please enter the code you see above
What is 5 + 6 =