#htmleditformat( _timingMessage )#
IF OBJECT_ID('#_clientMappedOperatorsTable#', 'U') IS NULL
BEGIN
select fsltablecode, ownerId, operatorId, fsl_choId, territoryId, inferredPurchasing
into #_clientMappedOperatorsTable#
from tbl_OPR_CLientOperators with (nolock)
where ownerId =
and fsltablecode =
and fsl_choId > 0
order by fsltablecode, ownerId, operatorId;
alter table #_clientMappedOperatorsTable# add constraint PK_#_clientMappedOperatorsTable# primary key ( fsltablecode, ownerId, operatorId );
END
IF OBJECT_ID('#_clientMappedOperatorsTable#', 'U') IS NOT NULL
DROP TABLE #_clientMappedOperatorsTable#;
delete tpf
from tbl_MFR_TPF_Detail#_tpfSuffix# tpf
where not exists (
select * from tbl_TPM_Requests r with (nolock)
where r.ownerId = tpf.mfr_id
and r.ownerType = 'MFR'
and r.requestId = tpf.rebateContractId
)
and tpf.forecast_status = 'C'
and nullif( rebateContractId, 0 ) is not null