EnVisageOnline/Main/Database/Scripts/20160504/01_sp_DeleteNonProjectTime.sql

33 lines
2.0 KiB
Transact-SQL
Raw Permalink 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.

USE [EnVisage]
GO
/****** Object: StoredProcedure [dbo].[sp_DeleteNonProjectTime] Script Date: 04.05.2016 23:15:23 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_DeleteNonProjectTime] (@id uniqueidentifier, @resourceId uniqueidentifier = null)
AS
BEGIN
begin transaction
delete from NonProjectTimeResourceAllocation
where NonProjectTime2ResourceId IN (
select Id from NonProjectTime2Resource where NonProjectTimeId = @id and (@resourceId is null or PeopleResourceId = @resourceId)
)
delete from NonProjectTimeTeamAllocation
where NonProjectTime2TeamId IN (
select Id from NonProjectTime2Team where NonProjectTimeId = @id
)
delete from NonProjectTime2Resource where NonProjectTimeId = @id and (@resourceId is null or PeopleResourceId = @resourceId)
delete from NonProjectTime2Team where NonProjectTimeId = @id
if(@resourceId is null)
begin
delete from NonProjectTime where Id = @id
end
commit transaction
END