Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

SSIS Multiple Joins on multiple tables on databases on different instances

$
0
0

Hello,

I am trying to perform the following sql statement in an SSIS package:

With Accessions as (
select 
      A.ACCESSION As Accession, 
      A.enbr1 As EncounterNbr,
      A.PROC_NBR as ProcedureNbr,
      A.ORD_TEST As OrderedTest,
      a.text as FootNote
from Cerner_Legacy_Dev.dbo.AN90_1 A 
where LTRIM(RTRIM(RCODE1)) in  ('20','21') 
AND LAST_VERSION = 'Y'
AND substring(ltrim(rtrim(a.accession)),1,3) != '00U'
and a.accession > ' ' 

)

--select * from Accessions order by Accession,EncounterNbr
Select distinct -- (non distinct returns 42291, distinct = 36109) 
      a.Accession,
      A.EncounterNbr,
      A.ProcedureNbr, 
      t1.mnemonic,
      ptp.ProcedureCodeName,
      A.OrderedTest,
      a.footnote,
      PA.AccessionID as AccessionId,
      PP.PatientProcedureID,
      pp.procedurename,
      ptp.PatientTestProcedureID,
      1 as SysytemSourceId
From Accessions A

join Procedures_TD000 T on ltrim(rtrim(A.OrderedTest)) = ltrim(rtrim(T.Test_Nbr))

join Procedures_TD000 T1 on ltrim(rtrim(A.ProcedureNbr)) = ltrim(rtrim(T1.Test_Nbr))

join patientaccessions PA on Ltrim(rtrim(A.Accession)) = Ltrim(rtrim(PA.CaseNumber))

join dbo.PatientProcedure PP  on PA.AccessionID = PP.AccessionID 
 and ltrim(rtrim(pp.ProcedureName)) = ltrim(rtrim(T.TEST_NAME))

join dbo.PatientTestProcedures PTP on pp.PatientProcedureID = PTP.PatientProcedureID
and t1.mnemonic = ptp.ProcedureCodeName


Some of the tables are residing on a database on server A, and the other tables are residing on a database on server B. 

I am unable to use this sql query in an OLE DB connection because of this, and I cannot use linked servers

In a test environment where these database are on the same server, the result came back with 78826 rows. 

I have have tested multiple solutions in SSIS from Merge Joins to Lookups and have been unable to get the same # of rows back. 

Could I please get some assistance with this? Any help would be greatly appreciated!

Thank you,

Jon


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>