I’ve perused the Help files, but I’m having some difficulty understanding how I would go about automating the following SQL selects. The only thing that changes in each of them is the date, which I’m guessing I would use a variable of some kind for.
Currently, these are each run by hand - 2 of them are run once daily, the other is run twice daily at different times. Each is exported to Excel and saved to a shared folder, then emailed to a TO and CC distro lists from Outlook.
Can someone point me in the right direction for figuring out how to automate these? Your help is much appreciated.
Script 1: Once per day, prior to 0830, date is previous day
SELECT idst_wip.acctcorp, idst_wip.house, idst_wip.cust,
idst_wip.wstat, idst_wip.pts, idst_wip.wordate, idst_wip.wloc,
idst_wip.w1st5, idst_wip.sa, idst_wip.who, idst_wip.tcrectim,
idst_wip.schdat, idst_wip.mgt, idst_wip.ftax, idst_wip.changeopr,
idst_wip.qtaslot, idst_wip.mustdo, idst_wip.schedondate,
idst_wip.compliance, idst_wip.tcstartby, idst_wip.reschnotdone,
idst_wip.svcintrpt, idst_wip.newwproty, idst_box_inventory.bnumb,
idst_box_inventory.addleq, idst_box_inventory.mfg,
idst_box_inventory.purchdate, idst_box_inventory.loc, idst_box_inventory.bxstatus,
idst_box_inventory.addrsable, idst_box_inventory.evtcpbl, idst_box_inventory.hibit,
idst_box_inventory.outlet, idst_box_inventory.opr, idst_box_inventory.boxequip
FROM idst_wip join idst_box_inventory ON
idst_wip.acctcorp = idst_box_inventory.acctcorp AND
idst_wip.house = idst_box_inventory.house AND
idst_wip.cust = idst_box_inventory.cust
WHERE idst_wip.acctcorp IN (05705, 32007) AND
idst_wip.wstat = ‘F’ AND
idst_wip.schdat > DATE ‘2010-12-10’ AND
idst_box_inventory.bxstatus = ‘D’ AND
idst_box_inventory.fmt = ‘A’
Script 2: Once per day, prior to 0830, date is the previous day, run at the same time as script 1
SELECT acctcorp,
tech,
wstat,
RESCHNOTDONE,
Count (*),
Sum(pts)
FROM idst_wip
WHERE acctcorp IN (05705, 32007)
AND wpcddate = DATE ‘2010-12-10’
GROUP BY acctcorp, tech, wstat, RESCHNOTDONE
Script 3: Twice per day, at 1100 and 1400, date is the current day:
SELECT idst_cdw_detail.acctcorp, idst_cdw_detail.cddate, idst_cdw_detail.tech, idst_cdw_detail.dseq, idst_cdw_detail.house,
idst_cdw_detail.dcstat, idst_cdw_detail.wordrsn, idst_cdw_detail.wjob, idst_cdw_detail.pts
FROM idst_cdw_detail
WHERE idst_cdw_detail.acctcorp IN (05705, 32007) AND
idst_cdw_detail.wjob IN (1, 2, 3, 4, 7, 8) AND idst_cdw_detail.cddate = DATE ‘2010-12-12’
I realize this SQL is not the cleanest, but I didn’t write it