33 lines
2.4 KiB
Transact-SQL
33 lines
2.4 KiB
Transact-SQL
/*
|
||
Run this script on SQL Server 2008 or later. There may be flaws if running on earlier versions of SQL Server.
|
||
*/
|
||
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_DeleteScenario]') AND type in (N'P', N'PC'))
|
||
DROP PROCEDURE [dbo].[sp_DeleteScenario]
|
||
GO
|
||
SET QUOTED_IDENTIFIER ON
|
||
GO
|
||
SET ANSI_NULLS ON
|
||
GO
|
||
CREATE PROCEDURE [dbo].[sp_DeleteScenario] (@aScenarioOID uniqueidentifier) AS
|
||
BEGIN
|
||
|
||
BEGIN TRANSACTION
|
||
|
||
delete from dbo.TeamAllocation where ScenarioId = @aScenarioOID
|
||
delete from dbo.Team2Scenario where ScenarioId = @aScenarioOID
|
||
delete from dbo.CostSaving where ScenarioId = @aScenarioOID
|
||
delete from dbo.PeopleResourceAllocation where ScenarioId = @aScenarioOID
|
||
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
|