EnVisageOnline/Main/Database/Scripts/20141114/05_sp_DeleteProject.sql

33 lines
817 B
Transact-SQL

USE [EnVisage]
GO
/****** Object: StoredProcedure [dbo].[sp_DeleteProject] Script Date: 14.11.2014 17:10:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_DeleteProject] (@id uniqueidentifier) AS
BEGIN
BEGIN TRANSACTION
select Id into #scenarioId2Delete from Scenario where Scenario.ParentId = @id
delete from History where EntityId in (select id from #scenarioId2Delete)
delete from Note where ParentId in (select id from #scenarioId2Delete)
delete from Rate where ParentId in (select id from #scenarioId2Delete)
delete from ScenarioDetail where ScenarioDetail.ParentID in (select id from #scenarioId2Delete)
delete from Scenario where id in (select id from #scenarioId2Delete)
delete from Project where id = @id
COMMIT TRANSACTION
END
GO