select fsl_choId, operatorId, fsl_choIdBy, fsl_choIdDate, fsl_choIdStatus, fsl_choIdTrace, oprCompanyType, independentYN, oprParentCo, companyName, mfrCustNum from tbl_OPR_ClientOperators bep where fsltablecode = 'MSC' and ownerId = 226 and nullif( mfrCustNum, '' ) is not null and fsl_choId > 0 and exists ( select *from tbl_OPR_ClientOperators co where co.companyName like '%' + ltrim( rtrim( bep.mfrCustNum )) + '%' and fsl_choId = 492621 and fsl_choIdTrace like 'CHO:612%' ) and mfrCustNum = 'BMDIDV' UPDATE tbl_OPR_ClientOperators SET FSL_choId = 0, fsl_choIdStatus = 'X', fsl_choIdDate = , fsl_choIdBy = -1, oprParentCo = null, independentYN = 1, oprCompanyType = '0' WHERE OwnerID = 226 AND FSLTableCode = 'MSC' AND operatorId = and fsl_choId > 0 update tbl_OPR_ClientOperators set fsl_choId = , fsl_choIdStatus = , fsl_choIdDate = , fsl_choIdBy = , fsl_choIdTrace = , oprCompanyType = , independentYN = , oprParentCo = where ownerId = 226 and fsltablecode = 'MSC' and operatorId = select eventId, eventName, eventTime, eventData, eventSubjectId, eventSubjectType, eventUserId from tbl_SYS_events with (nolock) where ownerId = and ownerType = and eventSubjectType = and eventSubjectId in ( ) and eventTime >= '10/15/2020 4:00pm' order by eventId select mfrCustNum from tbl_OPR_ClientOperators with (nolock) where ownerId = and fsltablecode = and operatorId = select fsl_choIdDate, ownerId, fsltablecode, operatorId from tbl_OPR_ClientOperators with (nolock) where fsl_choId > 0 and fsl_choIdTrace = and ownerId > 0 union all select distinct o.fsl_choIdDate, o.ownerId, o.fsltablecode, o.operatorId from tbl_OPR_ClientOperators o with (nolock) inner join tbl_CRM_Affiliations a with (nolock) on a.ownerId = o.ownerId and a.ownerType = o.fsltablecode and a.partnerId = o.operatorId and a.partnerType = 'OPR' and a.orgType = 'OPR' where o.fsltablecode = 'MFR' and o.ownerId > 0 and o.oprCompanyType != '0' and o.fsl_choIdTrace is null and a.partnerAffiliateNbr = and o.fsl_choId = order by fsl_choIdDate desc