select * from tbl_EAI_inboundFileFormats with (nolock) where formatName = '1FS_DISTRIBUTOR_EXPORT_TXT' and ownerId = 0 and ownerType = '*' with holdingCompanies as ( select hd.dstId from tbl_DST_Distributors hd where exists ( select * from tbl_DST_Distributors pd where pd.dstParentCo = hd.dstId and pd.dstCompanyType = 'P' ) and hd.dstCompanyType = 'P' and not exists ( select * from tbl_DST_Distributors bd where bd.dstParentCo = hd.dstId and bd.dstCompanyType = 'B' ) ) select dst.dstid distributor_1fs_id, case when hc.dstId is not null then 'HOLDING' else dst.dstCompanyType end distributor_type, dst.dstname distributor_name, dst.dstaddr1 distributor_address, dst.dstcity distributor_city, dst.dstState distributor_state, dst.dstZip distributor_zipcode, pcdr.fsl_dstId parent_1fs_id, 0 buying_group_1fs_id, '' parent_1fs_name, '' buying_group_1fs_name from tbl_CDR_Distributors cdr with (nolock) inner join tbl_DST_Distributors dst with (nolock) on dst.dstid = cdr.fsl_dstId left outer join holdingCompanies hc on hc.dstId = dst.dstId left outer join tbl_CDR_Distributors pcdr with (nolock) on pcdr.fsl_dstId = dst.dstParentCo and pcdr.fsl_dstId > 0 and pcdr.fsl_mapPriority = 1 and pcdr.ownerId = cdr.ownerId and pcdr.fsl_tablecode = cdr.fsl_tablecode where cdr.ownerId = and cdr.fsl_tablecode = and cdr.fsl_mapPriority = 1 union select byg.uniqueId + #_buyingGroupIDOffset# distributor_1fs_id, 'G' distributor_type, byg.name distributor_name, byg.address distributor_address, byg.city distributor_city, byg.state distributor_state, byg.zipcode distributor_zipcode, 0 parent_1fs_id, 0 buying_group_1fs_id, '' parent_1fs_name, '' buying_group_1fs_name from tbl_CDR_Distributors cdr with (nolock) inner join tbl_BYG_BuyingGroups byg with (nolock) on byg.uniqueId = cdr.fslBuyingGroupId where cdr.ownerId = and cdr.fsl_tablecode = and cdr.fsl_dstId = 0 order by distributor_1fs_id select byg.uniqueId from tbl_CDR_Distributors cdr with (nolock) inner join tbl_BYG_BuyingGroups byg with (nolock) on byg.uniqueId = cdr.fslBuyingGroupId where cdr.ownerId = and cdr.fsl_tablecode = and cdr.fsl_dstId = 0 select distinct a.partnerId as dstId from tbl_CRM_Affiliations a with (nolock) inner join tbl_CDR_Distributors cdr with (nolock) on cdr.fsl_dstId = a.partnerId and cdr.fsl_mapPriority = 1 where a.ownerId = 66 and a.ownerType = 'MSC' and a.orgType = 'BYG' and a.orgId = and a.partnerType = 'DST' and a.affiliationStatus = 'A' and cdr.ownerId = and cdr.fsl_tablecode =

1FS Master Records #lsnumberformat( qmd_1fsMaster.recordCount )#

select *, '' customer_nbr, '' customer_name from qmd_1fsMaster where 1 = 2 select cdr.cdr_dstCode, cdr.cdr_dstName from tbl_CDR_Distributors cdr with (nolock) inner join tbl_BYG_BuyingGroups byg with (nolock) on byg.uniqueId = cdr.fslBuyingGroupId where cdr.ownerId = and cdr.fsl_tablecode = and cdr.fsl_dstId = 0 and byg.uniqueId = and nullif( cdr.cdr_dstCode, '' ) is not null select cdr.cdr_dstCode, cdr.cdr_dstName from tbl_CDR_Distributors cdr with (nolock) inner join tbl_DST_Distributors dst with (nolock) on dst.dstId = cdr.fsl_dstId where cdr.ownerId = and cdr.fsl_tablecode = and cdr.fsl_dstId = and nullif( cdr.cdr_dstCode, '' ) is not null

1FS Master Plus Records #lsnumberformat( qmd_1fsMasterPlus.recordCount )#

#min( qmd_1fsMasterPlus.recordCount, _maxRows )##qmd_1fsMasterPlus.recordCount# rows exported
FTP Queued: #htmleditformat( _v )#
FTP NOT QUEUED
update tbl_EAI_inboundBatches set fileName = , ttlDays = 365 where batchId = and ownerId = and ownerType =