"日期与int"不兼容错误,但没有INT参数

时间:2017-01-30 23:19:19

标签: sql-server-2012

我在SQL Server 2012中构建SP。我收到错误消息:

  

操作数类型冲突:日期与int不兼容。

正如您所看到的,我的存储过程中没有INT参数。

任何人都可以弄清楚我错过了什么吗?

CREATE PROCEDURE DailyTickets2 

    @rd0 DATE = NULL, 
    @rd1 DATE = NULL,
    @rd2 DATE = NULL

AS

    SET NOCOUNT ON;

BEGIN

    SET @rd0 = GETDATE()
    SET @rd1 = DATEADD(day,-1,@rd0)
    SET @rd2 = DATEADD(day,-2,@rd0)

-- Queued Tickets---
(
SELECT
    SUM(CASE WHEN JOB_TICKET.JOB_TICKET_ID <= @rd1 AND JOB_TICKET.CLOSE_DATE IS NULL OR JOB_TICKET.CLOSE_DATE > @rd1
        THEN 1 ELSE 0
        END) AS rd1Queue,
    SUM(CASE WHEN JOB_TICKET.JOB_TICKET_ID <= @rd2 AND JOB_TICKET.CLOSE_DATE IS NULL OR JOB_TICKET.CLOSE_DATE > @rd2
        THEN 1 ELSE 0
        END) AS rd2Queue
    FROM JOB_TICKET
    WHERE JOB_TICKET.MERGED_PARENT_TICKET_ID IS NULL 
        AND JOB_TICKET.DELETED = 0 
)
UNION ALL
(
SELECT
    SUM(CASE WHEN JOB_TICKET.REPORT_DATE >= @rd1 AND JOB_TICKET.REPORT_DATE < @rd0
        THEN 1 ELSE 0
        END) AS rd1Opened,
    SUM(CASE WHEN JOB_TICKET.REPORT_DATE >= @rd2 AND JOB_TICKET.REPORT_DATE < @rd1
        THEN 1 ELSE 0
        END) AS rd2Opened
FROM JOB_TICKET
WHERE JOB_TICKET.MERGED_PARENT_TICKET_ID IS NULL 
        AND JOB_TICKET.DELETED = 0 
)
UNION ALL
(
SELECT
    SUM(CASE WHEN JOB_TICKET.CLOSE_DATE >= @rd1 AND JOB_TICKET.CLOSE_DATE < @rd0 
        THEN 1 ELSE 0
        END) AS rd1Closed,
    SUM(CASE WHEN JOB_TICKET.CLOSE_DATE >= @rd2 AND JOB_TICKET.CLOSE_DATE < @rd1
        THEN 1 ELSE 0
        END) AS rd2Closed
FROM JOB_TICKET
WHERE JOB_TICKET.MERGED_PARENT_TICKET_ID IS NULL 
        AND JOB_TICKET.DELETED = 0 
)
END
GO

0 个答案:

没有答案