hi,
Sir i want to access records from two tables one from a database and other from different database ?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SenthilkumarPosted Apr 17, 2012, 11:35 PM
Yes, you can do it easily if both databases comes under the same sql server machine.
For example,
I have two database called Products and another database called Sales
My application connected with the ProductsMaster database
you need to create the object for the table with the correct database.
It will give the joined results.
Hope this will help you.
Jignesh TrivediPosted Apr 17, 2012, 11:33 PM
Hi,
If we have these two database on same Database server then directly use these tables.
Example:
I have two database like db1 and db2 and have tables table1 and table2 respectively.
Select col1 as COL1 from db1..table1
union
Select col2 as COL1 from db2..table2
OR
Select col1 as COL1 from db1..table1 t1
INNer JOIN db2..table2 t2 ON t1.col1 = t2.col2
If these two db are on differnt server then use linked server.
hope this help.
Sam HobbsPosted Apr 17, 2012, 1:36 PM