Read the doctor from a database, to the B Database Timing Alert table, filter has been read to the ID
SELECTa.ID doctor's order Id, A.medordtype category, A.inhosid hospitalization number, A.execofficeid department code, a.starttime start time, C.patientname name, D.office department name fromDatabase A.dbo.mst_longdoctoradvice A--Left JOIN NEWHISMessageWarning.dbo.MessageWarning b on 1 = 1 Left JOINDatabase A.dbo.basecom_patient C onA.inhosid=C.diagnoseid Left JOINDatabase A.dbo.basecom_office D onD.officeid=A.execofficeidWHEREa.ID not inch(SELECTYzid fromDatabase b.dbo.messagewarningWHEREYzlx= 1 ); SELECTa.ID doctor's order Id, A.medordtype category, A.inhosid hospitalization number, A.execofficeid department code, a.starttime start time, C.patientname name, D.office department name fromDatabase A.dbo.mst_tempdoctoradvice A--Left JOIN NEWHISMessageWarning.dbo.MessageWarning b on 1 = 1 Left JOINDatabase A.dbo.basecom_patient C onA.inhosid=C.diagnoseid Left JOINDatabase A.dbo.basecom_office D onD.officeid=A.execofficeidWHEREa.ID not inch(SELECTYzid fromDatabase b.dbo.messagewarningWHEREYzlx= 2);
SQL Server two Database federated query