-2

I have a program that output results from database but the source of data comes from five databases. Is it possible to output the data coming from five databases? Thank you.

2 Answers2

0

sample select query for getting data from multiple database

SELECT * FROM DB1.dbo.MyTable
 UNION ALL
 SELECT * FROM DB2.dbo.MyTable
sekaraja
  • 177
  • 1
  • 1
  • 8
0

yes its possible. Try like below query:

**

select  DD.DISTRICT_NAME, MM.MANDAL_NAME,GP_NAME from 
(
select  District_id,substring(sn_vo_id,3,4) as mandal,Gp_id,sn_vo_id,MEMBER_ID,sn_member_name,sn_amount_paid_date,Project_Type_ID,Activity,status
from pop_nov18..tbl_scsp_hlp_new where   hh_id is  null and MEMBER_ID not in
 (select MEMBER_ID from pop_nov18..IB_SHG_MEMBER_DETAILS)  
) a left join UnnathiMasters.[dbo].[vo_master] vo on a.sn_vo_id=vo.VO_id
left join UnnathiMasters.[dbo].[gp_master] GP on a.Gp_id=GP.GP_ID
left join UnnathiMasters.[dbo].[mandal_master] MM on a.mandal=mm.MANDAL_ID
left join UnnathiMasters.[dbo].[district_master] DD on a.District_id=DD.DISTRICT_ID
left join SC_ST_Bluefrog_2013..SCSP_HLP_MASTER AC on a.Activity=AC.sub_activity_code

**

In above query,POP_nov18,UnnathiMasters and SC_ST_Bluefrog_2013 are three different databases.

Rajesh G
  • 44
  • 4