﻿USE [FabApprovalSystem]
GO
	/****** Object:  UserDefinedFunction [dbo].[fnIsUserITARCompliant]    Script Date: 11/21/2024 11:31:55 AM ******/
SET
	ANSI_NULLS ON
GO
SET
	QUOTED_IDENTIFIER ON
GO
	-- =============================================
	-- Author:		<Author,,Name>
	-- Create date: <Create Date,,>
	-- Description:	<Description,,>
	-- =============================================
	CREATE FUNCTION [dbo].[fnIsUserITARCompliant] (@UserID INT) RETURNS TABLE AS RETURN (
		-- Add the SELECT statement with parameter references here
		--SELECT SAM.* FROM [TEM-CDB02].SAM.dbo.vwSamActiveUsersWithSupervisorID  SAM
		SELECT
			SAM.*
		FROM
			SAMUsers SAM
			INNER JOIN Users U ON SAM.UserID = U.LoginID
		WHERE
			HasITARAccess = 1
			AND U.UserID = @UserID -- Return the result of the function
	)
GO