select * from tbl_IMPORT_BlackSmithClientCompanies where eai_batchId = and company_type in ( 'LOCATION', 'Operator') select distinct client_name from qmd_getBatchRecords select mfr_id from tblManufacturers where mfr_name = update tbl_IMPORT_BlackSmithClientCompanies set fseMfrId = where client_name = and ownerId = and ownerType = and eai_batchId = and coalesce(nullif( fseMfrId, null ),0) = 0 select distinct client_code from qmd_getBatchRecords select mfr_id from tblManufacturers where mfr_code = update tbl_IMPORT_BlackSmithClientCompanies set fseMfrId = where client_code = and ownerId = and ownerType = and eai_batchId = --and active = 1 and contractee = 1 select client_code, client_name, company_type,company_id, client_company_id, client_company_name from tbl_IMPORT_BlackSmithClientCompanies with (nolock) where eai_batchId = and coalesce(nullif( fseMfrId, null ),0) = 0 and ( contractee is null or contractee = case when nullif(client_code,'') is not null then 1 end ) and company_type in ('LOCATION', 'OPERATOR') select distinct 'OPR' rec_type, client_company_name as company_name, client_company_address as company_address1, client_company_city as company_city, client_company_state as company_state, client_company_zip as company_zip , CONVERT( varchar, fseMfrId ) + ':' + company_id as company_id , 'C' as company_priority from tbl_IMPORT_BlackSmithClientCompanies bsc with (nolock) where eai_batchId = and ownerId = and ownerType = and nullif( client_company_name, '' ) is not null and nullif( client_company_id, '' ) is not null and ( contractee is null or contractee = case when nullif(client_code,'') is not null then 1 end ) and fseMfrId > 0 and company_type in ('LOCATION', 'OPERATOR') order by company_name select territoryId, internalSalesId, name from tbl_TER_Territories with (nolock) where ownerId = and fsl_tablecode = order by territoryId insert into tbl_TER_Territories ( ownerId, fsl_tablecode, name, internalSalesId, levelId ) values ( , , 'All Markets', 'ZZZ', 0 ) ---> select opr.operatorId, opr.companyName, opr.address, opr.city, opr.state, opr.zipcode from tbl_IMPORT_BlackSmithClientCompanies bsc with (nolock) inner join tbl_OPR_ClientOperators opr with (nolock) on opr.ownerId = bsc.ownerId and opr.fslTableCode = bsc.ownerType and opr.mfrCustNum = CONVERT( varchar, bsc.fseMfrId ) + ':'+ bsc.company_id where bsc.eai_batchId = and bsc.ownerId = and bsc.ownerType = select rowId from tbl_EAI_InboundFileProcessors with (nolock) where ownerId = and ownerType = and fileFormat = 'BASE_OPERATORS_TXT' and fileProcessor = '/mstrQueries/utilityQueries/DataImport/Operators/baseOperatorImport.cfm' insert into tbl_EAI_inboundFileProcessors ( ownerId, ownerType, fileName, fileFormat, fileProcessor, processingWindowStartHr24, processingWindowLengthHr, autoProcess, allowUpload, allowFTP, allowEmail, notifications, clientProcessEmail, fseProcessEmail, defaultBatchClass ) values ( , , '^nothing\.txt$', 'BASE_OPERATORS_TXT', '/mstrQueries/utilityQueries/DataImport/Operators/baseOperatorImport.cfm', 0, 24, 'Y', 'N', 'N', 'N', 'N', 'data-czar@system-message.com', 'batch-admin@system-message.com', 'A' ) update tbl_EAI_inboundBatches set queueStatus = 0, status = 'PENDING', dependentBatchId = where ownerId = and ownerType = and batchId =