40 lines
908 B
Transact-SQL
40 lines
908 B
Transact-SQL
USE [FabApprovalSystem]
|
|
GO
|
|
/****** Object: UserDefinedFunction [dbo].[fn_IsECNITAR] 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].[fn_IsECNITAR] (
|
|
-- Add the parameters for the function here
|
|
@ECNNumber INT
|
|
) RETURNS INT AS BEGIN -- Declare the return variable here
|
|
DECLARE @Count INT -- Add the T-SQL statements to compute the return value here
|
|
SET
|
|
@Count = (
|
|
SELECT
|
|
COUNT(*)
|
|
FROM
|
|
ECN E
|
|
WHERE
|
|
(
|
|
(
|
|
E.IsRH = 1
|
|
AND E.IsAU = 0
|
|
AND E.IsIndustrial = 0
|
|
AND E.IsMA = 0
|
|
)
|
|
OR (IsDocEC = 1)
|
|
)
|
|
AND E.ECNNumber = @ECNNumber
|
|
) -- Return the result of the function
|
|
RETURN @Count
|
|
END
|
|
GO |