select distinct dopr.operatorId, dopr.distrib1, dopr.distrib2, dopr.companyName, edi.shipToName, edi.distName, dcdr.cdr_recordId, dcdr.ownerId, dcdr.fsl_tablecode, dcdr.cdr_DstName from tbl_EDI_867 edi
inner join tbl_CDR_Distributors cdr
on cdr.cdr_recordId = edi.fseCdrRecordId
and cdr.ownerId = edi.ownerId
and cdr.fsl_tablecode = edi.ownerType
inner join tbl_CDR_Distributors dcdr
on dcdr.fsl_dstId = cdr.fsl_dstId
and dcdr.fsl_dstId > 0
inner join tbl_OPR_ClientOperators dopr
on dopr.mfrCustNum = edi.shipToAcctNum
and dopr.ownerId = dcdr.ownerId
and dopr.fsltablecode = dcdr.fsl_tablecode
where edisenderid = 'EFSBBSYSCO'
and dcdr.ownerId = 4036
and dcdr.fsl_tablecode = 'DST'
and edi.ownerId = 54
and edi.ownerType = 'MFR'
and left( edi.shipToName, 10 ) = left( dopr.companyName, 10 )
update tbl_OPR_ClientOperators
set distrib1 =
where operatorId =
and ownerId = 4036
and fsltablecode = 'DST'
and nullif( distrib1, 0 ) is null
Condition 2
update tbl_OPR_ClientOperators
set distrib2 =
where operatorId =
and ownerId = 4036
and fsltablecode = 'DST'
and nullif( distrib2, 0 ) is null
Condition 2b #operatorId#|#cdr_recordId#
Condition 3
update tbl_OPR_ClientOperators
set distrib2 =
where operatorId =
and ownerId = 4036
and fsltablecode = 'DST'
and nullif( distrib2, 0 ) is null
Condition 3b #operatorId#|#cdr_recordId#
Condition 4