select fileFormat, fileProcessor, fseProcessEmail, clientProcessEmail, processingWindowStartHr24, processingWindowLengthHr from tbl_EAI_InboundFileProcessors where ownerId = and ownerType = and fileFormat = set nocount on insert into tbl_EAI_InboundBatches ( batchTime, expireTime, ownerId, ownerType, FileName, fileFormat, fileProcessor, fseProcessEmail, clientProcessEmail, status, queueStatus, lineCount, config ) values( , , , , , 'BASE_OPERATORS_TXT', , , , , -1, , ) select batchId = @@identity set nocount off INSERT INTO tbl_IMPORT_Operators(eai_lineNumber, eai_batchid, ownerId, ownerType, company_name, company_address1, company_city, company_state, company_zip, company_segment, company_sub_segment, company_dst1_name, affiliate_nbr, affiliation_orgName, affiliation_type, rec_type, affiliate_date, territory_id, contact_first_name, contact_last_name, contact_email, contact_title, external_ID) SELECT DISTINCT MIN( eai_lineNumber) eai_LineNumber, #qry_createJob.batchid#, ownerId, ownerType, company_name, company_address1, company_city, company_state, company_zip, company_segment, company_sub_segment, company_dst1_name, affiliate_nbr, affiliation_orgName, affiliation_type, 'OPR', affiliate_date, territory_id, contact_first_name, contact_last_name, contact_email, contact_title, MIN( eai_lineNumber) eai_LineNumber FROM tbl_IMPORT_CRORebates WHERE eai_batchID = and fseInclude = 'Y' GROUP BY eai_batchId, ownerId, ownerType, company_name, company_address1, company_city, company_state, company_zip, company_segment, company_sub_segment, company_dst1_name, affiliation_type, affiliate_nbr, affiliation_orgName, affiliate_date, territory_id, contact_first_name, contact_last_name, contact_email, contact_title ORDER BY eai_linenumber