delete from tbl_EXPORT_Kellanova_Distributor where ownerId = and ownertype = and eai_batchId = insert into tbl_EXPORT_Kellanova_Distributor( eai_batchid, eai_linenumber, ownerid, ownerType, novalytics_distributor_id, distributor_code, distributor_name, street_address_1, street_address_2, city, state, zip_code, phone_number, createDate, data_source, divisionname, division_region, distributor_territory, sales_rep_first_name, sales_rep_last_name, sales_rep_email, classification, priority_level, parent_distributor, accounttype, buyingGroup, primary_contact, primary_contact_novalytics_id, comments ) select #attributes.batchId#, row_number() over( order by cdr_dstname ) as eai_lineNumber, #qmd_batch.ownerId#, '#qmd_batch.ownerType#', cdr_recordId, cdr_dstcode, cdr_dstname, cdr_dstaddress1, cdr_dstaddress2, cdr_dstcity, cdr_dststate, cdr_dstzip, cdr_dstPhone, createDate, recordSource, divisionName, regionName, territoryName, terManagerFirstName, terManagerLastName, terManagerEmail, classificationname, cdr_priority, parentCdrDstName, /*dstcompanytype,*/ case when dstcompanytype = 'B' then 'DISTRIBUTOR' when dstcompanytype = 'R' then 'REDISTRIBUTOR' when dstcompanytype = 'S' then 'SPECIAL' when dstcompanytype = 'P' then 'PARENT' when dstcompanytype = 'O' then 'OPERATOR' when dstcompanytype = 'G' then 'BUYING GROUP' else 'UNKNOWN' end as dstcompanytype, bgName, primaryContactFirstName + ' ' + primaryContactLastName primaryContactFullName, primaryContactId, comments from tbl_DW_CRMDistributors_MFR207 with (nolock) where dstcompanyType in ('B','P','G') order by cdr_dstname update tbl_EAI_InboundBatches set loadedColumns = 'novalytics_distributor_id,distributor_code,distributor_name,street_address_1,street_address_2,city,state,zip_code,phone_number,createDate,data_source,divisionname,division_region,distributor_territory,sales_rep_first_name,sales_rep_last_name,sales_rep_email,classification,priority_level,parent_distributor,accounttype,buyingGroup,primary_contact,primary_contact_novalytics_id,comments' where ownerId = and ownertype = and batchId =
Exported #lsnumberformat( _exportCount )# Distributors.
select * from tbl_EXPORT_Kellanova_Distributor with (nolock) where ownerId = and ownertype = and eai_batchId = order by eai_lineNumber