51 lines
1.3 KiB
Transact-SQL
51 lines
1.3 KiB
Transact-SQL
USE [FabApprovalSystem]
|
|
GO
|
|
/****** Object: StoredProcedure [dbo].[ECNGetExpiredDocuments] Script Date: 11/21/2024 11:29:04 AM ******/
|
|
SET
|
|
ANSI_NULLS ON
|
|
GO
|
|
SET
|
|
QUOTED_IDENTIFIER ON
|
|
GO
|
|
-- =============================================
|
|
-- Author: <Author,,Name>
|
|
-- Create date: <Create Date,,>
|
|
-- Description: <Description,,>
|
|
-- =============================================
|
|
CREATE PROCEDURE [dbo].[ECNGetExpiredDocuments] AS BEGIN -- 2019/02/14 added ISNULL to ExpirationInProgress
|
|
-- SET NOCOUNT ON added to prevent extra result sets from
|
|
-- interfering with SELECT statements.
|
|
SET
|
|
NOCOUNT ON;
|
|
|
|
-- Insert statements for procedure here
|
|
SELECT
|
|
E.ECNNumber,
|
|
CASE
|
|
WHEN E.ExtensionDate IS NOT NULL THEN E.ExtensionDate
|
|
ELSE ExpirationDate
|
|
END AS ExpirationDate,
|
|
U.Email,
|
|
CurrentStep
|
|
FROM
|
|
ECN E
|
|
INNER JOIN Users U ON E.OriginatorID = U.UserID
|
|
WHERE
|
|
IsTECN = 1
|
|
AND CancellationApproved = 0
|
|
AND CancellationInProgress = 0
|
|
AND ExpirationProcessed = 0
|
|
AND ISNULL(ExpirationInProgress, 0) = 0
|
|
AND ConversionApprovalInProgress = 0
|
|
AND (
|
|
(
|
|
CAST(ExtensionDate AS DATE) <= CAST(GETDATE() AS DATE)
|
|
) -- Get the docs hat expire the next day
|
|
OR (
|
|
ExtensionDate IS NULL
|
|
AND CAST(ExpirationDate AS DATE) <= CAST(GETDATE() AS DATE)
|
|
) -- Get the docs hat expire the next day
|
|
)
|
|
AND CloseDate IS NOT NULL
|
|
END
|
|
GO |