Client Automation - All Version
SELECT A.agent_name 'Computer Name',
R2.itemname 'INSTALL Package Name', R2.itemversion 'INSTALL Package Version', P2.itemname 'INSTALL Procedure Name', dateadd(ss, datediff(ss,getutcdate(),getdate())+INST.completiontime, convert(datetime, '19700101')) 'INSTALL Time',
R.itemname 'UNINSTALL Package Name', R.itemversion 'UNINSTALL Package Version', P.itemname 'UNINSTALL Procedure Name', dateadd(ss, datediff(ss,getutcdate(),getdate())+ UNINST.completiontime, convert(datetime, '19700101')) 'UNINSTALL Time'
FROM usd_applic INST
INNER JOIN usd_applic UNINST ON UNINST.installation=INST.objectid
LEFT JOIN usd_actproc P ON UNINST.actproc=P.objectid
LEFT JOIN usd_rsw R ON R.objectid=P.rsw
LEFT JOIN usd_actproc P2 ON INST.actproc=P2.objectid
LEFT JOIN usd_rsw R2 ON R2.objectid=P2.rsw
LEFT JOIN ca_agent A ON UNINST.target=A.object_uuid
WHERE p.task=1 and UNINST.status=9 and INST.uninstallstate<>2 and
INST.status=9 and INST.installation=INST.objectid
ORDER BY A.agent_name, R.itemname, R.itemversion, P.itemname
UPDATE usd_applic
SET uninstallstate=2
FROM usd_applic
INNER JOIN usd_applic UNINST ON UNINST.installation=usd_applic.objectid
LEFT JOIN usd_actproc P ON UNINST.actproc=P.objectid
WHERE p.task=1 and UNINST.status=9 and usd_applic.uninstallstate<>2 and
usd_applic.status=9 and usd_applic.installation=usd_applic.objectid