USE [EnVisage]
GO

/****** Object:  StoredProcedure [dbo].[sp_DeleteScenario]    Script Date: 2/25/2015 5:50:24 PM ******/
DROP PROCEDURE [dbo].[sp_DeleteScenario]
GO

/****** Object:  StoredProcedure [dbo].[sp_DeleteScenario]    Script Date: 2/25/2015 5:50:24 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[sp_DeleteScenario] (@aScenarioOID uniqueidentifier) AS
	BEGIN
	
		BEGIN TRANSACTION

		delete from History where EntityId = @aScenarioOID
		delete from Note where ParentId = @aScenarioOID
		delete from Rate where ParentId = @aScenarioOID
		delete from ScenarioDetail where ScenarioDetail.ParentID = @aScenarioOID
		delete from Scenario2Group where ScenarioId = @aScenarioOID
		delete from PeopleResourceAllocation where ScenarioId = @aScenarioOID
		delete from Team2Scenario where ScenarioId = @aScenarioOID
		delete from CostSaving where ScenarioId = @aScenarioOID
		delete from Scenario where id = @aScenarioOID

		COMMIT TRANSACTION 

 	END




GO


