with dd as ( --- list of assigned distributor account numbers select distinct dd.accountNumber, dst.dstId, dst.dstBranchId, dst.dstParentCo, dst.dstName from tbl_OPR_DistributionDetails dd inner join tbl_CDR_Distributors cdr on cdr.cdr_recordId = dd.cdr_recordId and cdr.ownerId = dd.ownerId and cdr.fsl_tablecode = dd.ownerType inner join tbl_DST_Distributors dst on dst.dstId = cdr.fsl_dstId where nullif( dd.accountNumber, '' ) is not null ) -- dst operators with account number but no assigned primray distributor select o.ownerId, o.fsltablecode, o.operatorId, o.companyName, o.city, o.state, o.zipcode, o.mfrCustNum, o.distrib1, dd.*, cdr.cdr_recordId, cdr.cdr_dstName, cdr.cdr_dstCity, cdr.cdr_dstState from tbl_OPR_CLientOperators o left outer join dd on dd.accountNumber = o.mfrCustNum and dd.dstparentCo = o.ownerId left outer join tbl_CDR_Distributors cdr on cdr.ownerId = o.ownerId and cdr.fsl_tablecode = o.fsltablecode and cdr.fsl_dstId = dd.dstId and cdr.fsl_mapPriority = 1 and cdr.cdr_dstCompanyType = 'B' where nullif( mfrCustNum, '' ) is not null and o.ownerId > 0 and o.fsltablecode = 'DST' and nullif( o.distrib1, 0 ) is null order by o.operatorId update tbl_OPR_CLientOperators set distrib1 = where ownerId = and fsltablecode = and operatorId =
1. Set #htmleditformat(companyName)# in #htmleditformat( city )#, #htmleditformat( state )# to #htmleditformat( cdr_dstName )# in #htmleditformat( cdr_dstCity )#, #htmleditformat( cdr_dstState )#
select cdr_recordId, cdr_dstName, cdr_dstCity, cdr_dstState from tbl_CDR_Distributors where ownerId = and fsl_tablecode = and fsl_dstId = and fsl_mapPriority = 1 and cdr_dstCompanyType = 'B' insert into tbl_CDR_Distributors ( fsl_tablecode, ownerId, cdr_dstName, cdr_dstAddress1, cdr_dstCity, cdr_dstState, cdr_dstZip, fsl_dstId, fsl_mapPriority, cdr_dstCompanyType, recordSource ) select '#fsltablecode#' fsl_tablecode, #ownerId# ownerId, dstName cdr_dstName, dstAddr1 cdr_dstAddress1, dstCity cdr_dstCity, dstState cdr_dstState, dstZip cdr_dstZip, dstId fsl_dstId, 1 fsl_mapPriority, dstCompanyType cdr_dstCompanyType, 'findAndSetPrimaryDistributor #lsdateformat( now(), "MM/DD/YYYY" )#' recordSource from tbl_DST_Distributors where dstId = and dstCompanyType = 'B' select cdr_recordId, cdr_dstName, cdr_dstCity, cdr_dstState from tbl_CDR_Distributors where ownerId = and fsl_tablecode = and cdr_recordId =
Added #dstId# #htmleditformat( qmd_branchCheck.cdr_dstName )# in #htmleditformat( qmd_branchCheck.cdr_dstCity )#, #htmleditformat( qmd_branchCheck.cdr_dstState )#
update tbl_OPR_CLientOperators set distrib1 = where ownerId = and fsltablecode = and operatorId =
2. Set #htmleditformat( companyName )# in #htmleditformat( city )#, #htmleditformat( state )# to #htmleditformat( qmd_branchCheck.cdr_dstName )# in #htmleditformat( qmd_branchCheck.cdr_dstCity )#, #htmleditformat( qmd_branchCheck.cdr_dstState )#

Rolling Back