select * from tbl_IMPORT_PartnerContacts with (nolock) where eai_batchId = and eai_lineNumber = 1 select imp.* from tbl_IMPORT_PartnerContacts imp with (nolock) inner join tbl_FSPro_members mem with (nolock) on mem.ownerId = imp.ownerId and mem.fsl_tablecode = imp.ownerType and mem.fspro_userId = imp.fspro_userId where imp.eai_batchId = and imp.ownerId = and imp.ownerType = and imp.eai_lineNumber > 0 update tbl_IMPORT_PartnerContacts set fseUpdateStatus = 'M', fseContactId = where ownerId = and ownertype = and eai_batchid = and eai_lineNumber = and eai_importId = select imp.eai_importId, imp.ownerId, imp.ownerType, imp.fspro_userId, imp.recordSource, imp.company_id, imp.company_name, imp.contact_last_name, imp.contact_first_name, imp.contact_phone,imp.contact_mobile_phone, imp.contact_email, imp.contact_type, imp.contact_title, imp.contact_zip, imp.contact_state, imp.contact_city, imp.contact_address1, imp.contact_function, imp.company_type, imp.eai_batchId, imp.eai_lineNumber, imp.fseContactId, imp.fseUpdateStatus from tbl_IMPORT_PartnerContacts imp with (nolock) where imp.ownerId = and imp.ownerType = and imp.eai_batchId = and imp.fseUpdateStatus = 'M' and imp.fseContactId is not null select imp.eai_importId, imp.ownerId, imp.ownerType, imp.fspro_userId, imp.recordSource, imp.company_id, imp.company_name, imp.contact_last_name, imp.contact_first_name, imp.contact_phone, imp.contact_mobile_phone, imp.contact_email,imp.contact_type, imp.contact_title, imp.contact_zip, imp.contact_state, imp.contact_city, imp.contact_address1, imp.contact_function, imp.company_type, imp.eai_batchId, imp.eai_lineNumber, imp.fseContactId, imp.fseUpdateStatus from tbl_IMPORT_PartnerContacts imp with (nolock) where imp.ownerId = and imp.ownerType = and imp.eai_batchId = and imp.fseUpdateStatus is null and imp.fseContactId is null and imp.company_id <> '' select operatorId from tbl_OPR_ClientOperators with (nolock) where operatorId = and ownerId = and fslTableCode = update tbl_IMPORT_PartnerContacts set fseUpdateStatus = 'N' where ownerId = and ownertype = and eai_batchid = and company_id = and fseUpdateStatus is null select cdr_recordId from tbl_CDR_Distributors with (nolock) where cdr_recordId = and ownerId = and fsl_TableCode = update tbl_IMPORT_PartnerContacts set fseUpdateStatus = 'N' where ownerId = and ownertype = and eai_batchid = and company_id = and fseUpdateStatus is null select jobFunctionId from qmd_partnerContactJobFunctions where UPPER(jobFunctionName) = set nocount on insert into tbl_FSPro_members ( firstName, lastName, title, email, phone, cellPhone, createDate, lastUpdated, originalSource, orgId, orgType, ownerId, fsl_tablecode, cajobfunction, address1, City, State, ZipCode ) values( , , , , , , , , , , , , , , , , , ) select contactId = @@identity set nocount off update tbl_IMPORT_PartnerContacts set fseUpdateStatus = , fseContactId = where eai_batchId = and eai_importId = and ownerId = and ownerType = select jobFunctionId from qmd_partnerContactJobFunctions where jobFunctionName = update m set m.firstName = , m.lastName = , m.title = , m.email = , m.failedEmail = case when failedEmail != '#_contactEmail#' then null else failedEmail end, m.failedEmailDate = case when failedEmail != '#_contactEmail#' then null else failedEmailDate end , m.failedEmailReason = case when failedEmail != '#_contactEmail#' then null else failedEmailReason end , m.phone = , m.cellPhone = , m.Address1 = , m.city = , m.state = , m.ZipCode = , m.cajobfunction = , m.orgId = , m.orgType = , m.lastUpdated = from tbl_FSPro_members m where m.ownerId = and m.fsl_tableCode = and m.FSPro_UserID = update tbl_IMPORT_PartnerContacts set fseUpdateStatus = 'U' where eai_batchId = and eai_importId = and fseUpdateStatus = 'M' and fseContactId = and ownerId = and ownerType = select contact_first_name, contact_last_name, contact_email, company_name, company_territory , company_type as contact_type from tbl_IMPORT_PartnerContacts with (nolock) where ownerId = and ownerType = and eai_batchId = and fseUpdateStatus = 'A' and fseContactId is not null select contact_first_name, contact_last_name, contact_email, company_name, company_territory, company_type as contact_type from tbl_IMPORT_PartnerContacts with (nolock) where ownerId = and ownerType = and eai_batchId = and fseUpdateStatus = 'U' and fseContactId is not null select contact_first_name, contact_last_name, contact_email, company_name, company_territory, company_type as contact_type from tbl_IMPORT_PartnerContacts with (nolock) where ownerId = and ownerType = and eai_batchId = and fseUpdateStatus is null and fseContactId is null select contact_first_name, contact_last_name, contact_email, company_name, concat( company_type, ' Not Found') as Reason from tbl_IMPORT_PartnerContacts with (nolock) where ownerId = and ownerType = and eai_batchId = and ( (fseUpdateStatus = 'N' and fseContactId is null) or (company_type = '')) select fseContactId as contactId, contact_first_name as FirstName, contact_last_name as LastName, case when contact_function in () then contact_function else '' end as contact_function from tbl_IMPORT_PartnerContacts with (nolock) where ownerId = and ownerType = and eai_batchId = and contact_function in () select fseContactId as contactId, contact_first_name as FirstName, contact_last_name as LastName, contact_email from tbl_IMPORT_PartnerContacts with (nolock) where ownerId = and ownerType = and eai_batchId = and contact_email in ()