Mike Phares ab800974b7 Programmability objects from database
Removed commented code
Added fn_GetExpiredTECNByOriginator
2024-12-12 12:15:46 -07:00

32 lines
929 B
Transact-SQL

USE [FabApprovalSystem]
GO
/****** Object: UserDefinedFunction [dbo].[fnGetScrapCount] 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].[fnGetScrapCount] (
-- Add the parameters for the function here
@IssueID INT
) RETURNS INT AS BEGIN -- Declare the return variable here
DECLARE @ScrapCount INT -- Add the T-SQL statements to compute the return value here
SELECT
@ScrapCount = SUM(ScrapCount)
FROM
LotDisposition LD
INNER JOIN Lot L ON LD.IssueID = L.IssueID
INNER JOIN ScrapLot S ON L.IssueID = S.IssueID
AND L.LotNumber = S.LotNo
WHERE
LD.IssueID = @IssueID
AND ScrapCount > 0 -- Return the result of the function
RETURN @ScrapCount
END
GO