select bol.TerritoryID from tbl_SMA_BrokerOfficeLink bol with (nolock) inner join tbl_ORG_AttributeLinks oal with (nolock) on oal.mstr_attrTypeID = 34 and oal.mstr_attrID = and oal.child_attrTypeID = 27 and oal.child_attrID = bol.BrokerOfficeID inner join tblBrokerOffices bo with (nolock) on bo.BROKER_OFFICE_ID = oal.child_attrID where nullif(bol.territoryId,0) is not null select distinct mfr.mfr_id, mfr.mfr_name, mfr.mfrabbrev_name from tblManufacturers mfr with (nolock) inner join tblMfrBrokerLink mbl with (nolock) on mbl.MFR_ID = mfr.MFR_ID and exists ( select * from tbl_PRD_SKUs with (nolock) where OwnerID = and FSL_TableCode = and MfrID = mfr.MFR_ID ) where mbl.BROKER_ID = select mfr.mfr_id, mfr.mfr_name, mfr.mfrabbrev_name from tblManufacturers mfr with (nolock) where MFR_ID in ( select distinct mfrid from tbl_PRD_SKUs with (nolock) where OwnerID = and FSL_TableCode = ) select distinct bol.mfr_id from tbl_SMA_BrokerOfficeLink bol with (nolock) inner join tbl_ORG_AttributeLinks oal with (nolock) on oal.mstr_attrTypeID = 34 and oal.mstr_attrID = and oal.child_attrTypeID = 27 and oal.child_attrID = bol.BrokerOfficeID inner join tblbrokeroffices bo with (nolock) on bo.broker_office_id = bol.brokerofficeid where bol.brokerid = select mfr.mfr_id, mfr.mfr_name, mfr.mfrabbrev_name from tblManufacturers mfr with (nolock) where mfr.mfr_id in () order by mfr.MFR_NAME select mfr.mfr_id, mfr.mfr_name, mfr.mfrabbrev_name from tblManufacturers mfr with (nolock) where mfr.mfr_id in () order by mfr.MFR_NAME select distinct mfr.mfr_id, mfr.mfr_name, mfr.mfrabbrev_name from tblManufacturers mfr with (nolock) inner join tbl_SMA_BrokerOfficeLink bol with (nolock) on bol.MFR_ID = mfr.mfr_id inner join tbl_ORG_AttributeLinks oal with (nolock) on oal.mstr_attrTypeID = 34 and oal.mstr_attrID = and oal.child_attrTypeID = 27 and oal.child_attrID = bol.BrokerOfficeID inner join tblbrokeroffices bo with (nolock) on bo.broker_office_id = bol.brokerofficeid where mfr.mfr_id in () and mfr.mfr_id <> 6500 and mfr.mfr_id <> 6868 and exists ( select * from tbl_PRD_SKUs with (nolock) where OwnerID = mfr.MFR_ID and FSL_TableCode = 'mfr' ) order by mfr.MFR_NAME select m.mfr_id, m.mfr_name from fsenablers.dbo.tbl_app_configurations c with (nolock) left outer join tblmanufacturers m with (nolock) on m.mfr_id = c.ownerid where c.applicationcode = '1fsbsr' and c.ownertype = 'mfr' and c.parametername = 'apps.distributorSalesData.enabled' and c.parametervalue = 'true' and m.mfr_id in () and exists ( select * from tbl_SMA_BrokerOfficeLink bol with (nolock) inner join tbl_ORG_AttributeLinks oal with (nolock) on oal.mstr_attrTypeID = 34 and oal.mstr_attrID = and oal.child_attrTypeID = 27 and oal.child_attrID = bol.BrokerOfficeID where bol.MFR_ID = m.mfr_id ) and exists ( select * from tbl_cdr_distributors with (nolock) where ownerid = m.mfr_id and fsl_tablecode = 'mfr' and mfr_bsr_id = and crmactive = 'y' ) order by m.mfr_name select m.mfr_id, m.mfr_name from fsenablers.dbo.tbl_app_configurations c with (nolock) left outer join tblmanufacturers m with (nolock) on m.mfr_id = c.ownerid where c.applicationcode = '1fsbsr' and c.ownertype = 'mfr' and c.parametername = 'apps.operatorSalesData.enabled' and c.parametervalue = 'true' select mfr.mfr_id from tblManufacturers mfr with (nolock) where mfr.mfr_id in ( ) and mfr.mfr_id in ( ) and exists ( select * from tbl_SMA_BrokerOfficeLink bol with (nolock) inner join tbl_ORG_AttributeLinks oal with (nolock) on oal.mstr_attrTypeID = 34 and oal.mstr_attrID = and oal.child_attrTypeID = 27 and oal.child_attrID = bol.BrokerOfficeID where bol.MFR_ID = mfr.mfr_id ) select 'OK' where exists ( select interactionid from tbl_CRM_Interactions with (nolock) where OwnerID = and OwnerType = ) select 'OK' where exists ( select * from tbl_CDR_InvoiceHistory with (nolock) where OwnerID = and OwnerType = ) #_nothingToSeeHere# #_newOutput#