if object_id('[#_tempTable#]', 'U') is not null drop table [#_tempTable#]; with export as ( SELECT cdr.cdr_recordId as dist_id, cdr.cdr_dstcode as dist_code, cdr.cdr_dstname as company_name, cdr.cdr_dstaddress1 as company_address1, cdr.cdr_dstaddress2 as company_address2, cdr.cdr_dstcity as company_city, cdr.cdr_dststate as company_state, cdr.cdr_dstzip as company_zip_code, cdr.cdr_dstPhone as company_phone, cdr.divisionName as division_name, cdr.regionName as region_name, cdr.territoryName as territory_name, cdr.territoryid as territory_id, cdr.mfr_bsr_id as rep_id, cdr.cmFirstName as rep_first_name, cdr.cmLastName as rep_last_name, cdr.cmEmail as rep_email, case when cdr.cdr_priority = '*' then 'A+' else cdr.cdr_priority end as priority, cdr.parentCdrDstName as parent_distributor FROM tbl_DW_CRMDistributors_#qmd_batch.ownerType##qmd_batch.ownerId# cdr with (nolock) WHERE cdr.OwnerID = AND cdr.ownerType = AND cdr.dstcompanytype = 'B' ) select * into [#_tempTable#] from export;
Exported #lsnumberformat( _exportCount )# Distributors
update tbl_EAI_inboundBatches set fileName = , ttlDays = 365 where batchId = and ownerId = and ownerType =