select distinct expcategory, fy from tbl_IMPORT_SSD_TradeExpenseHistory where eai_batchId = and ownerType = and ownerId = select requestId, payableTo from tbl_TPM_Requests where assignedContractNbr = and startDate = and ownerType = and ownerId = update tbl_IMPORT_SSD_TradeExpenseHistory set fseRequestId = , fsePartnerType = where eai_batchId = and ownerType = and ownerId = and expcategory = and fy = select distinct custopernum, fsePartnerType, fseRequestId from tbl_IMPORT_SSD_TradeExpenseHistory where eai_batchId = and ownerType = and ownerId = and fseRequestId > 0 select operatorId from tbl_OPR_ClientOperators where mfrcustnum = and fsltablecode = and ownerId = update tbl_IMPORT_SSD_TradeExpenseHistory set fsePartnerId = where eai_batchId = and ownerType = and ownerId = and custopernum = and fsePartnertype = and fseRequestId = select cdr.cdr_recordId from tbl_CDR_Distributors cdr inner join tbl_CDR_DstCodes cdrc on cdrc.cdr_RecordId = cdr.cdr_recordId and cdrc.ownerId = cdr.ownerId and cdrc.ownerType = cdr.fsl_tablecode where cdrc.cdr_dstcode = and cdrc.ownerType = and cdrc.ownerId = update tbl_IMPORT_SSD_TradeExpenseHistory set fsePartnerId = where eai_batchId = and ownerType = and ownerId = and custopernum = and fsePartnertype = and fseRequestId = select eai_importId, fseRequestId, fsePartnerId, fsePartnerType, ssdDollars, fy, expcategory from tbl_IMPORT_SSD_TradeExpenseHistory where eai_batchId = and ownerType = and ownerId = and fseRequestId > 0 and fsePartnerId > 0 select claimId from tbl_TPM_Claims where partnerId = and partnerType = and claimedRequestId = and ownerType = and ownerId = update tbl_IMPORT_SSD_TradeExpenseHistory set fseClaimId = , fseClaimStatus = 'R' where eai_batchId = and eai_importId = insert into tbl_TPM_Claims( ownerId, ownertype, partnerId, partnerType, claimAmount, verifiedAmount, reconciledAmount, claimStatus, claimPeriodStart, claimPeriodEnd, claimDate, claimedRequestId, claimInvoice, claimRef, claimDescription, claimType, createDate, createUserId, updateDate, updateuserId, claimStatusComment, volumeBased ) values( , , , , , , , 'APPROVED', , , , , , , , 'D', , 0, , 0, , 'N' ) insert into tbl_TPM_ClaimContracts ( ownerId, ownertype, claimId, contractNbr, requestId, subClaimAmount, approvedAmount, manualClaimAmount, verifiedAmount, reconciled, status, statusComment ) values( , , , , , , , , , 'Y', 'APPROVED_CLAIMAMT', 'Expense History batch #qmd_batch.batchId#' ) update tbl_IMPORT_SSD_TradeExpenseHistory set fseClaimId = , fseClaimStatus = 'A' where eai_batchId = and eai_importId = select distinct expcategory, convert( datetime, '01-01-' + convert( varchar, fy )) startDate from tbl_IMPORT_SSD_TradeExpenseHistory where eai_batchId = and fseRequestId is null select distinct case when fsePartnerType = 'OPR' then 'OPERATOR' else 'DISTRIBUTOR' end accountType, custopernum, ssdname from tbl_IMPORT_SSD_TradeExpenseHistory where eai_batchId = and fsePartnerId is null and fsePartnerType is not null select case when fsePartnerType = 'OPR' then 'OPERATOR' else 'DISTRIBUTOR' end accountType, custopernum, ssdname, fy, expcategory, ssdDollars, case when fseClaimStatus = 'R' then 'Recalculated' when fseClaimStatus = 'A' then 'Added' else 'Unknown' end action, fseClaimId claimId from tbl_IMPORT_SSD_TradeExpenseHistory where fseClaimId > 0 and eai_batchId =