select mfr_name from tblManufacturers with (nolock) where mfr_id = update tbl_EAI_InboundBatches set comment = where ownerId = and ownerType = and batchId = and nullif( comment, '' ) is null select name from sys.tables where name = select distinct ter.internalSalesId manufacturer_TerritoryNbr, ter.name as manufacturer_territoryName, coalesce( pt.mfrTerritoryNbr, '' ) broker_TerritoryNbr from tbl_SMA_BrokerOfficeLink sma with (nolock) inner join tbl_TER_Territories ter with (nolock) on ter.territoryId = sma.territoryId and ter.ownerId = sma.mfr_id and ter.fsl_tablecode = 'MFR' inner join tbl_BRO_Principals bpl with (nolock) on bpl.ownerId = sma.brokerId and bpl.ownerType = 'BRO' and bpl.mfrId = sma.mfr_Id left outer join tbl_BRO_PrincipalTerritories pt with (nolock) on pt.ownerId = bpl.ownerId and pt.ownerType = bpl.ownerType and pt.principalId = bpl.principalId and pt.hireStatus = 'A' and pt.mfrTerritoryNbr = nullif( ter.internalSalesId, '' ) where sma.brokerid = and sma.mfr_id = order by internalSalesId

One or more territories are not properly aligned between the manufacturer and broker. In order for operator syncrhonization to take place for a territory, the broker must have the same territory number assigned as that which is provided by the manufacturer for that territory. The manufacturer assigned territory number must not be blank on the manufacturer side.

declare @brokerId int = ; declare @mfrId int = ; select distinct ter.territoryId as mfrTerritoryId, ter.internalSalesId manufacturer_TerritoryNbr, ter.name as manufacturer_territoryName, sma.brokerOfficeId, coalesce( pt.mfrTerritoryNbr, '' ) broker_TerritoryNbr, bter.territoryId, bter.name from tbl_SMA_BrokerOfficeLink sma with (nolock) inner join tbl_BRO_Principals bpl with (nolock) on bpl.ownerId = sma.brokerId and bpl.ownerType = 'BRO' and bpl.mfrId = sma.mfr_Id inner join tbl_TER_Territories ter with (nolock) on ter.territoryId = sma.territoryId and ter.ownerId = sma.mfr_id and ter.fsl_tablecode = 'MFR' inner join tbl_BRO_PrincipalTerritories pt with (nolock) on pt.ownerId = bpl.ownerId and pt.ownerType = bpl.ownerType and pt.principalId = bpl.principalId and pt.hireStatus = 'A' and pt.mfrTerritoryNbr = nullif( ter.internalSalesId, '' ) inner join tbl_BRO_PrincipalTerritoryResources ptr on ptr.ownerId = sma.brokerId and ptr.ownerType = 'BRO' and ptr.resourceType = 'BO' and ptr.resourceId = sma.brokerOfficeId and ptr.principalTerritoryId = pt.principalTerritoryId inner join tbl_BRO_PrincipalTerritoryResources ptr2 on ptr2.ownerId = ptr.ownerId and ptr2.ownerType = ptr.ownertype and ptr2.resourceType = 'TER' and ptr2.principalTerritoryId = pt.principalTerritoryId inner join tbl_TER_Territories bter on bter.ownerId = ptr2.ownerId and bter.fsl_tablecode = ptr2.ownerType and bter.territoryId = ptr2.resourceId where sma.brokerid = @brokerId and sma.mfr_id = @mfrId and sma.primaryOffice = 'Y' order by ter.internalSalesId declare @brokerId int = ; declare @mfrId int = ; select mo.operatorChoId, mo.operatorType, mo.operatorTerritoryId from #_1fsUniverseTable# mo with (nolock) where operatorPurchasing = 'Y' and operatorTerritoryId in ( select distinct ter.territoryId from tbl_SMA_BrokerOfficeLink sma with (nolock) inner join tbl_TER_Territories ter with (nolock) on ter.territoryId = sma.territoryId and ter.ownerId = sma.mfr_id and ter.fsl_tablecode = 'MFR' inner join tbl_BRO_Principals bpl with (nolock) on bpl.ownerId = sma.brokerId and bpl.ownerType = 'BRO' and bpl.mfrId = sma.mfr_Id inner join tbl_BRO_PrincipalTerritories pt with (nolock) on pt.ownerId = bpl.ownerId and pt.ownerType = bpl.ownerType and pt.principalId = bpl.principalId and pt.hireStatus = 'A' and pt.mfrTerritoryNbr = nullif( ter.internalSalesId, '' ) where sma.brokerid = @brokerId and sma.mfr_id = @mfrId /* too loosey goosey select distinct territoryId from tbl_SMA_BrokerOfficeLink sma with (nolock) where sma.brokerid = @brokerId and sma.mfr_id = @mfrId */ ) and operatorName not like '%blanket%' and not exists ( select * from tbl_OPR_ClientOperators opr with (nolock) where opr.ownerId = @brokerId and opr.fsltablecode = 'BRO' and opr.fsl_choId = operatorChoId ) order by operatorType
#htmleditformat( _r.sql )#
insert into tbl_LST_PartnerListItems ( listId, partnerId ) select #_listId# listId, #qmd_importedOperator.operatorId# partnerId where not exists ( select * from tbl_LST_PartnerListItems where listId = #_listId# and partnerId = #qmd_importedOperator.operatorId#)
#lsnumberformat( _importCount )#/#lsnumberformat( qmd_toSyndicate.recordCount )# 1FS Operators Imported - #_startTicks - getTickCount()#ms
#htmleditformat( _pingMessage )#
select listId from tbl_LST_partnerLists with (nolock) where ownerId = and ownerType = and listName = insert into tbl_LST_PartnerLists ( ownerId, ownerType, listName, locked, partnerType, createdBy, dateCreated, listType ) values ( , , , 'Y', 'OPR', -1, getDate(), 'SYSTEM' )