﻿USE [FabApprovalSystem]
GO
	/****** Object:  StoredProcedure [dbo].[MRBGetContainmentActions]    Script Date: 11/21/2024 11:29:05 AM ******/
SET
	ANSI_NULLS ON
GO
SET
	QUOTED_IDENTIFIER ON
GO
	CREATE PROCEDURE [dbo].[MRBGetContainmentActions] -- Add the parameters for the stored procedure here
	@MRBNumber INT AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
SET
	NOCOUNT ON;

-- 10/15/2018 changed to show rows where ResponsibilityOwnerID is NULL
SELECT
	ContainmentActionID,
	ContainmentAction,
	MRBNumber,
	ResponsibilityOwnerID,
	ResponsibilityOwnerID AS CurrentResponsibilityOwnerID,
	AssignedDate,
	ECD,
	ImplementedDate,
	CASE
		WHEN MC.ResponsibilityOwnerID IS NULL THEN MC.ResponsibilityOwner
		ELSE U.FirstName + ' ' + LastName
	END AS ResponsibilityOwner
FROM
	MRBContainmentAction MC
	LEFT OUTER JOIN Users U ON MC.ResponsibilityOwnerID = U.UserID
WHERE
	MRBNumber = @MRBNumber
END
GO