SQL Query help Inner Join in Script with two Databases

[code] qDowntimePDS = system.db.runPrepQuery(“SELECT dt.PlannedDT[Planned],sum(cast(DATEDIFF(ms,dt.begintime,dt.endtime) as int)) as Diff,pdt.ReasonCodeDescription[Reason] ,pdt.Note[Note],count(pdt.ReasonCodeDescription)[count] FROM DownTime dt inner join PROD_DownTime_Detail pdt on pdt.RefID=dt.ID where dt.runid=? and dt.PlannedDT = 0 AND pdt.SequenceDate BETWEEN ? AND ? group by dt.PlannedDT,pdt.ReasonCodeDescription,pdt.Note order by Diff desc”,[varRunID,startDateFormatted,endDateFormatted])

[/code]

Default Data Base for the Project name is MES.
This Query worked until I seperated the data base and put Analysis seperate.
“PROD_DownTime_Detail” is a schema in the Analysis database.
“DownTime” is a Scema in the MES database.

So I know I need to define Analysis somewhere I think at the end of line,“Analysis”)
But when you do this it can not find Downtime in the default database.

You cannot do this.
A query runs in a single database connection. That database actually identifies the schemas and table names given in the query. You will have to use the database’s own features for connecting two databases together.