I have Two Database on Same Server and I want to get Record from two Database in Single Sql Query Or Stored procedure
Server : 192.168.1.1
Database1 : Customer
Database2 : Product
DB : Customer à Table : CustomerPurchaseMaster
| ID | CustomerName | ProductID | OrderAmt |
| 1 | James | 1 | 125 |
| 2 | James | 2 | 220 |
| 3 | James | 3 | 300 |
DB: Product à Table : ProductMaster
| ProductID | ProductName |
| 1 | Pendrive |
| 2 | Mouse |
| 3 | Router |
Required Result Table Output
| ID | CustomerName | ProductName | OrderAmt |
| 1 | James | Pendrive | 125 |
| 2 | James | Mouse | 220 |
| 3 | James | Router | 300 |

Nanhe SiddiqueRank #1,103 · 1.7K reputationPosted Apr 24, 2015, 3:25 AM EDT
SELECT id,CustomerName,ProductName,OrderAmt FROM [ Customer].[dbo].[CustomerPurchaseMaster] tab1 INNER JOIN [Product].[dbo].[ProductMaster] tab2 ON tab1.ProductId= tab2.ProductIDSneha Sneha77 reputationPosted Apr 24, 2015, 2:21 AM EDT
Pnkl154 reputationPosted Apr 24, 2015, 3:19 AM EDT
I have to get record from two Different Database not from single Database in single query
Rajeev RanjanRank #373 · 6.8K reputationPosted Apr 24, 2015, 3:48 AM EDT
As i have seen your question.
This can be done by the three simple steps
1) Create a Link sever ( this process is done by any server admin)
2) get the Link server path
3) write our query [
Pnkl154 reputationPosted May 5, 2015, 4:54 AM EDT
Also, Your Answer is a accepted.
Thank you to Rajeev Ranjan And Nanhe Siddique