Can I use the below query to join 2 tables of different databases of same server. Also let me know in which database I have to execute this query.
SELECT ...
FROM A.table t1
JOIN B.table2 t2 ON t2.column = t1.col
Can I use the below query to join 2 tables of different databases of same server. Also let me know in which database I have to execute this query.
SELECT ...
FROM A.table t1
JOIN B.table2 t2 ON t2.column = t1.col
You just need to change that query a bit
Select * from Database1.[dbo].Table1 tab1
join Database2.[dbo].Table2 tab2 on tab1.ID = tab2.ID
or
Select * from Database1..Table1 tab1
join Database2..Table2 tab2 on tab1.ID = tab2.ID
Change names of databases, tables and IDs and give it a go
You can use it in all of connections on your server (every database), as your query have reference to databases