select distinct dd.accountNumber, opr.ownerId, opr.fsltablecode, opr.operatorId, oprQ.queueId as oprQueueId, oprQ.linkId as oprLinkId,
dstOpr.ownerId as dstOwnerId, dstOpr.fsltablecode as dstOwnerType, dstOpr.operatorId as dstOperatorId, dstOprQ.queueId as dstOprQueueId,
dstOprQ.linkId as dstOprLinkId, dstOpr.fsl_choId, dstOpr.companyName
from tbl_OPR_ClientOperators opr with (nolock)
left outer join tbl_OPR_DistributionDetails dd with (nolock)
on dd.ownerId = opr.ownerId
and dd.ownerType = opr.fsltablecode
and dd.operatorId = opr.operatorId
left outer join tbl_CDR_Distributors cdr with (nolock)
on cdr.ownerId = dd.ownerId
and cdr.fsl_tablecode = dd.ownerType
and cdr.cdr_recordId = dd.cdr_recordId
and cdr.crmActive = 'Y'
inner join tbl_DST_Distributors dst
on dst.dstId = cdr.fsl_dstId
left outer join tbl_OPR_ClientOperators dstOpr with (nolock)
on dstOpr.ownerId = dst.dstparentco
and dstOpr.fsltablecode = 'DST'
and dstOpr.mfrCustNum = dd.accountNumber
and nullif( dstOpr.mfrCustNum, '' ) is not null
left outer join tbl_1FS_MappingQueue oprQ with (nolock)
on oprQ.operatorOwnerId = opr.ownerId
and oprQ.operatorOwnerType = opr.fsltablecode
and oprQ.operatorId = opr.operatorId
left outer join tbl_1FS_MappingQueue dstOprQ with (nolock)
on dstOprQ.operatorOwnerId = dstOpr.ownerId
and dstOprQ.operatorOwnerType = dstOpr.fsltablecode
and dstOprQ.operatorId = dstOpr.operatorId
where opr.ownerId =
and opr.fsltablecode =
and nullif( opr.fsl_choId, 0 ) is null
and opr.crmActive = 'Y'
and nullif( dd.accountNumber, '' ) is not null
order by opr.operatorId, dstOpr.companyName
Operators with Customer Number:
select dstname as name from tbl_DST_Distributors with (nolock)
where dstid =
insert into tbl_1FS_MappingQueue ( queueDate, operatorOwnerId, operatorOwnerType, operatorId, linkLevel, mapCompanyType, listName ) values
(
,
,
,
,
,
,
)
select * from tbl_LST_PartnerListItems
where listId =
and partnerId =
insert into tbl_LST_PartnerListItems values
(
,
)