SELECT c.OwnerID, c.OwnerType ,threshold = COALESCE( (SELECT parameterValue FROM tbl_APP_Configurations c2 with(nolock) WHERE c.OwnerID = c2.OwnerID AND c.OwnerType = c2.OwnerType AND c2.applicationCode='SMPL' AND c2.parameterName = 'staleDraftOrdersProcessing.daysOldThreshold'), (SELECT parameterValue FROM tbl_APP_Configurations c3 with(nolock) WHERE c3.OwnerID = 0 AND c3.OwnerType = '*' AND c3.applicationCode='SMPL' AND c3.parameterName = 'staleDraftOrdersProcessing.daysOldThreshold') ) FROM tbl_APP_Configurations c with(nolock) WHERE c.ApplicationCode = 'SMPL' AND c.parameterName = 'staleDraftOrdersProcessing.enabled' AND c.parameterValue = 'true' AND c.ownerID = AND c.ownertype =

Number of stale Sample Orders deleted: #getEnabledClients.recordCount#

*** No stale Sample Orders have been deleted ***

UPDATE tbl_POS_OrderLineItems SET orderid = -orderid WHERE orderid IN (SELECT orderid FROM tbl_POS_Orders with(nolock) WHERE OwnerID = AND FSL_TableCode = AND orderdate < #CreateODBCDate(variables.ThresholdDate)# AND status = 'DR') UPDATE tbl_POS_Orders SET OwnerID = -OwnerID WHERE OwnerID = AND FSL_TableCode = AND orderdate < #CreateODBCDate(variables.ThresholdDate)# AND status = 'DR'