How to Retrieve Data From Tables Stored in Different Database in SQL

In this article I am going to explain how to retrieve data from tables stored in different database.
  • 2230

Introduction

In this article I am going to explain how to retrieve data from tables stored in different database. To  retrieve data from tables stored in different database we use inner join. For this we use server name, database name, name of database owner and name of table (object).

If server name is same than you can omit that part. In inner join we use JOIN, SELECT, ON and WHERE clause. INNER clause is optional in statement.

A Statement that create mcninvoices table

inv.jpg

Statements that insert data in mcninvoices table

inv (2).jpg

A Statement that is used to fetch data from mcninvoices table

inv111.jpg

A Statement that create vendors table

ven.jpg

Statements that insert data in vendors table

ven (1).jpg

A Statement that is used to fetch data from vendors table

ven (2).jpg

A Statement that retrieve data from tables stored in different database

Clipboard06.jpg


© 2019 DotNetHeaven. All rights reserved.