How can i get this to run faster, i'm accessing a access database and running this.
INSERT INTO FurnaceUsage ( JobNum, Process, ProcessNum, Temperature, CustCode, MatCode, Status, ProcessID, Hardness, JobComms )SELECT Trim(Processes.job) AS jobnum, Trim(processes.description) AS process, Trim(processes.SeqNo) AS ProcessNum, Trim(processes.Temperature) AS Temperature, Trim(Jobs.CustCode) AS CustCode, Trim(Jobs.MatCode) AS MatCode, 'WAITING' AS Status, Trim(processes.ID) AS ProcessID, Trim(JOBS.rc) AS Hardness, JobComments.COMMENTS AS JobComms FROM (Jobs INNER JOIN processes ON (Jobs.job = processes.job AND Jobs.Status=Processes.Description)) LEFT JOIN JobComments ON (JOBS.Comments = CStr(JobComments.ID)) WHERE (((processes.description)='TEMPERING' or trim(processes.description)='CYROGENIC TREATING -300') AND ((processes.WhereRun)='" & GlobalWHERERUN & "') AND ((Exists (Select JobNum FROM FurnaceUsage WHERE FurnaceUsage.JobNum=Processes.Job AND FurnaceUsage.ProcessNum=Processes.SeqNo AND Jobs.Custcode=furnaceusage.custcode and jobs.matcode=furnaceusage.matcode))=False));
It grabs all rows from one table that are not in a 2nd table and places them in the 2nd table. For some reason this takes a ton of time.
Please help!
David Kuhn
------------------
INSERT INTO FurnaceUsage ( JobNum, Process, ProcessNum, Temperature, CustCode, MatCode, Status, ProcessID, Hardness, JobComms )SELECT Trim(Processes.job) AS jobnum, Trim(processes.description) AS process, Trim(processes.SeqNo) AS ProcessNum, Trim(processes.Temperature) AS Temperature, Trim(Jobs.CustCode) AS CustCode, Trim(Jobs.MatCode) AS MatCode, 'WAITING' AS Status, Trim(processes.ID) AS ProcessID, Trim(JOBS.rc) AS Hardness, JobComments.COMMENTS AS JobComms FROM (Jobs INNER JOIN processes ON (Jobs.job = processes.job AND Jobs.Status=Processes.Description)) LEFT JOIN JobComments ON (JOBS.Comments = CStr(JobComments.ID)) WHERE (((processes.description)='TEMPERING' or trim(processes.description)='CYROGENIC TREATING -300') AND ((processes.WhereRun)='" & GlobalWHERERUN & "') AND ((Exists (Select JobNum FROM FurnaceUsage WHERE FurnaceUsage.JobNum=Processes.Job AND FurnaceUsage.ProcessNum=Processes.SeqNo AND Jobs.Custcode=furnaceusage.custcode and jobs.matcode=furnaceusage.matcode))=False));
It grabs all rows from one table that are not in a 2nd table and places them in the 2nd table. For some reason this takes a ton of time.
Please help!
David Kuhn
------------------