我在传递日期参数时遇到问题。
我收到错误
从字符串转换日期时间时转换失败。
我的存储过程如下,请告诉我该怎么做,
ALTER PROCEDURE [dbo].[WEEKLY_REPORT_PROC](
@START_DATE DATETIME,
@END_DATE DATETIME,@PRACTISE_NAME NVARCHAR(MAX))--,
-- @D1 DECIMAL(5,2),
-- @D2 DECIMAL(5,2),
-- @D3 DECIMAL(5,2),
-- @D4 DECIMAL(5,2),
-- @D5 DECIMAL(5,2),
-- @D6 DECIMAL(5,2),
-- @D7 DECIMAL(5,2))
AS
BEGIN
EXEC SP_EXECUTESQL @QUERY
DECLARE CP_DETAILS CURSOR FOR SELECT * FROM #TEMP
OPEN CP_DETAILS
FETCH NEXT FROM CP_DETAILS INTO @RESOURCE_NAME,@DAY1,@DAY2,@DAY3,@DAY4,@DAY5,@DAY6,@DAY7,@UTILIZATION
WHILE (@@FETCH_STATUS =0)
BEGIN
SET @UTILIZATION = dbo.UTILIZATION(@START_DATE,@END_DATE,@DAY1, @DAY2,@DAY3,@DAY4,@DAY5,@DAY6,@DAY7)
--INSERT INTO @WEEKLY_REPORT_DETAILS_INFORMATION VALUES(@RESOURCE_NAME,
-- @DAY1,@DAY2,@DAY3,@DAY4,@DAY5,@DAY6,@DAY7,@UTILIZATION)
UPDATE #TEMP SET UTILIZATION = @UTILIZATION WHERE RESOURCE_NAME=@RESOURCE_NAME
FETCH NEXT FROM CP_DETAILS INTO @RESOURCE_NAME,@DAY1,@DAY2,@DAY3,@DAY4,@DAY5,@DAY6,@DAY7
END
CLOSE CP_DETAILS
DEALLOCATE CP_DETAILS
SELECT * FROM #TEMP
--SELECT DBO.RETRIEVE(@QUERY) AS QUERY FROM CP_DETAILS
PRINT @QUERY
DROP TABLE #TEMP
RETURN
END
END
在中间我使用一个用户定义的函数utilization
,并将参数作为日期字段传递