Use [EnVisage]

IF EXISTS(SELECT * FROM sys.views WHERE Name = N'VW_ScenarioActualsReplacePoints')
BEGIN
	DROP VIEW VW_ScenarioActualsReplacePoints
	PRINT 'VW_ScenarioActualsReplacePoints dropped'
END
GO

CREATE VIEW [dbo].[VW_ScenarioActualsReplacePoints] AS
SELECT A.ParentID AS ForecastScenarioId, A.ExpenditureCategoryId, A.WeekEndingDate FROM ScenarioDetail A
INNER JOIN VW_ScenarioRelations C ON (A.ParentID = C.ForecastScenarioId)
INNER JOIN VW_ScenarioActualsPeriod D ON (C.ActualsScenarioId = D.ScenarioId) AND (A.WeekEndingDate > D.EndDate)
WHERE C.ForecastScenarioType <> 9
EXCEPT 
SELECT M.ForecastScenarioId, K.ExpenditureCategoryId, K.WeekEndingDate FROM ScenarioDetail K
INNER JOIN Scenario L ON (K.ParentID = L.Id)
INNER JOIN VW_ScenarioRelations M ON (K.ParentID = M.ActualsScenarioId)
WHERE L.[Type] = 9 and K.ExpenditureCategoryId in (select ExpenditureCategoryId from ScenarioDetail where ScenarioDetail.ParentID = M.ForecastScenarioId)