select distinct cdr.cdr_territoryId from tbl_IMPORT_SalesCalls i inner join tbl_CDR_Distributors cdr with (nolock) on i.ownerid = cdr.ownerid and i.ownerType = cdr.fsl_tableCode and cdr.cdr_dstName = i.call_distributor_Name where i.ownerid = and i.ownerType = and i.eai_batchid = select distinct s.call_date from tbl_IMPORT_SalesCalls s where s.eai_batchId = and s.ownerId = and s.ownerType = --and COALESCE(call_date,'') <> '' /* 10/8/24 SCRUM 61418. WAS MESSING WITH TBD CALLS */ select c.* from tbl_EAI_ChildBatches c where c.batchId = and c.ownerId = and c.ownerType = select c.* from tbl_EAI_ChildBatches c where c.childBatchId = and c.ownerId = and c.ownerType = select s.eai_importid, s.call_Date from tbl_IMPORT_SalesCalls s where s.eai_batchId = and s.ownerId = and s.ownerType = order by call_date update tbl_IMPORT_SalesCalls set eai_batchId = where eai_importId in ( #_idsToReassign# ) and ownerId = and ownerType = #resultsHTML# #_batchId#

#resultsHTML#

Source file attached.