EnVisageOnline/Main/Database/Scripts/20150622/01_spDeleteScenario_Proc_Up...

30 lines
2.5 KiB
Transact-SQL
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- SA. Update of the Scenario delete procedure
USE [envisage]
Go
ALTER PROCEDURE [dbo].[sp_DeleteScenario] (@aScenarioOID uniqueidentifier) AS
BEGIN
BEGIN TRANSACTION
--SA. ENV-885. Remove links to the template, if the scenario, we are going to delete, is a template
update dbo.Scenario set TemplateId = null where TemplateId = @aScenarioOID
delete from dbo.TeamAllocation where ScenarioId = @aScenarioOID
delete from dbo.Team2Scenario where ScenarioId = @aScenarioOID
delete from dbo.CostSaving where ScenarioId = @aScenarioOID --SA. ENV-885
delete from dbo.PeopleResourceAllocation where ScenarioId = @aScenarioOID --SA. ENV-885
delete from dbo.Scenario2Group where ScenarioId = @aScenarioOID --SA. ENV-885
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 Scenario_Snapshot where ParentID = @aScenarioOID
delete from Scenario_Wide where ScenarioId = @aScenarioOID
delete from ScenarioAccess where ScenarioAccess.ParentId = @aScenarioOID
delete from Scenario where id = @aScenarioOID
COMMIT TRANSACTION
END
GO