I have two databases on one sql server, and I have to link two tables from one DB server to two tables in another DB server to get the info that I need. The problem is tha
If you rewrote your FROM clause to use ANSI 92 you would get this
FROM CXADMIN.RO_FAILURE_DTL RF
INNER JOIN CXADMIN.RO_HIST RH
ON RF.REPAIR_ORD = RH.REPAIR_ORD
,
saadmin.sa_repair_part@elgsad rp
INNER JOIN saadmin.sa_code_group_task_dtl@elgsad cg
ON RP.REPAIR_ORD = CG.REPAIR_ORD
It then becomes easy to see that you've created a cartesian product between RF join RH and RP JOIN CG
You need to JOIN RF to RP or CG, or RH to RP or CG
for example
FROM CXADMIN.RO_FAILURE_DTL RF
INNER JOIN CXADMIN.RO_HIST RH
ON RF.REPAIR_ORD = RH.REPAIR_ORD
INNER JOIN saadmin.sa_repair_part@elgsad rp
ON RF.REPAIR_ORD = RP.REPAIR_ORD
INNER JOIN saadmin.sa_code_group_task_dtl@elgsad cg
ON RP.REPAIR_ORD = CG.REPAIR_ORD
Or if you insist on using ANSI-86 style joins you can just add AND RF.REPAIR_ORD = RP.REPAIR_ORD to your Where clause