美好的一天,我在存储过程中收到 2 个可为空的日期参数。@StartDate 和@EndDate。如果这两个参数为 NULL,我需要正常执行我的过程,否则 @StartDate 参数需要 >= 我的 StartDateTime 值和 @EndDate 参数需要 <= 我的 EndDateTime 值。下面是我正在尝试完成但不确定语法的片段。
    FROM DI_Intervention_Schedule S
    WHERE
        (
            @ID IS NULL
        OR  S.[ID] = @ID
        )
    AND (
            CASE @StartDate WHEN IS NOT NULL THEN
                @StartDate >= S.[StartDateTime] AND @EndDate <= S.[EndDateTime]
            END
        )
请问有什么帮助吗?