﻿USE [FabApprovalSystem]
GO
	/****** Object:  StoredProcedure [dbo].[_8DDeleteAuditFinding]    Script Date: 11/21/2024 11:29:03 AM ******/
SET
	ANSI_NULLS ON
GO
SET
	QUOTED_IDENTIFIER ON
GO
	-- =============================================
	-- Author:		<Author,,Name>
	-- Create date: <Create Date,,>
	-- Description:	<Description,,>
	-- =============================================
	CREATE PROCEDURE [dbo].[_8DDeleteAuditFinding] -- Add the parameters for the stored procedure here
	@AuditFindingsID INT AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
SET
	NOCOUNT ON;

DECLARE @AuditNo int
SELECT
	@AuditNo = AuditNo
FROM
	_8DAuditFinding
WHERE
	ID = @AuditFindingsID
DELETE FROM
	_8DAuditFinding
WHERE
	ID = @AuditFindingsID
DELETE FROM
	_8DAuditFindingCategoryByAuditFinding
WHERE
	AuditFindingID = @AuditFindingsID -- 11/26/2018 TR - maintain audit score when findings are deleted
	EXEC [_8DUpdateAuditScore] @AuditNo
END
GO