select distinct cbsc_id from tbl_IMPORT_JMS_ERFStatus where nullif( cbsc_id, '' ) is not null and ownerId = and ownerType = and eai_batchId = select operatorId from tbl_OPR_ClientOperators where mdmType = 'CBS' and mdmId = and ownerId = and fsltablecode = update tbl_IMPORT_JMS_ERFStatus set fseOperatorId = , fseOperatorMethod = 'C' where cbsc_id = and ownerId = and ownerType = and eai_batchId = select distinct customer_id from tbl_IMPORT_JMS_ERFStatus where nullif( customer_id, '' ) is not null and ownerId = and ownerType = and eai_batchId = and fseOperatorId is null select fieldId from tbl_OPR_Fields where name = 'FEAST_ID' and ownerId = and ownerType = select partnerId as operatorId from tbl_OPR_FieldValues where data = and fieldId = and partnerType = 'OPR' select operatorId from tbl_OPR_ClientOperators where ownerId = and fsltablecode = and operatorId = update tbl_IMPORT_JMS_ERFStatus set fseOperatorId = , fseOperatorMethod = 'F' where customer_id = and ownerId = and ownerType = and eai_batchId = and fseOperatorId is null select distinct salesperson from tbl_IMPORT_JMS_ERFStatus where nullif( salesperson, '' ) is not null and ownerId = and ownerType = and eai_batchId = select fspro_userId from tbl_FSpro_members where firstName = and lastName = and staffMember = 1 and loginEnabled = 1 and ownerId = and fsl_tablecode = select fspro_userId from tbl_FSpro_members where firstName = and lastName = and staffMember = 1 and loginEnabled = 1 and ownerId in ( select brokerid from tbl_SMA_BrokerOfficeLink where mfr_id = and 'MFR' = ) and fsl_tablecode = 'BRO' update tbl_IMPORT_JMS_ERFStatus set fseUserId = where salesPerson = and ownerId = and ownerType = and eai_batchId = select fseUserId, fseOperatorId, erf, order_status, erf_receive_date, hold_reason, reasoncode, appointment_date, formdate, eai_lineNumber from tbl_IMPORT_JMS_ERFStatus where ownerId = and ownerType = and eai_batchId = and nullif( erf, '' ) is not null select processId from tbl_WRK_ProcessDefinitions where processCode = 'ERF' and ownerId = and ownerType = select processInstanceId, userId, partnerId, statusDetail, status from tbl_WRK_ProcessInstances where ownerId = and ownerType = and referenceNbr = and processId = select processInstanceId, userId, partnerId, statusDetail, status from tbl_WRK_ProcessInstances where ownerId = and ownerType = and nullif( referenceNbr, '' ) is null and processId = and partnerId = and partnerType = 'OPR' and userId = and convert( date, startTime ) = insert into tbl_WRK_ProcessInstances ( ownerType, ownerId, processId, referenceNbr, status, statusDetail, createDate, updateDate, startTime, userId, partnerId, partnerType ) values( , , , , , , , , , , , ) update tbl_WRK_processInstances set updateDate = , statusDetail = , userId = , partnerId = , archive = 'N' , referenceNbr = case when nullif( referenceNbr, '' ) is null then else referenceNbr end where ownerId = and ownerType = and processId = and processInstanceId = and status = 'COMPLETE' update tbl_IMPORT_JMS_ERFStatus set fseProcessInstanceId = where eai_batchId = and ownerId = and ownerType = and eai_lineNumber = select cbsc_id, customer_id, customer_name ,address1, city, state, zip, parent, min( eai_lineNumber ) firstLine, count(*) lineCount from tbl_IMPORT_JMS_ERFStatus where eai_batchId = and fseOperatorId is null and fseProcessInstanceId is null group by cbsc_id, customer_id, customer_name ,address1, city, state, zip, parent order by firstLine select salesperson, min( eai_lineNumber ) firstLine, count(*) lineCount from tbl_IMPORT_JMS_ERFStatus where eai_batchId = and nullif( salesPerson, '' ) is not null and fseUserId is null group by salesperson order by firstLine