我写了一个sp基本上是为了检查日期之间的差异如果diff是4或2那么sp运行并且不会引发错误。
CREATE PROCEDURE AML_DATECHECK
@ALERTDAY VARCHAR
AS
IF((SELECT "DAY_DESC" =
CASE WHEN DATEDIFF(DAY,CONVERT(VARCHAR,"BUSINESS_DAY",120),
CONVERT(VARCHAR,CONVERT(VARCHAR,'@ALERTDAY',121),120))= 4
THEN 'BUSINESS DAY IS FRIDAY'
WHEN DATEDIFF(DAY,CONVERT(VARCHAR,"BUSINESS_DAY",120),
CONVERT(VARCHAR,CONVERT(VARCHAR(25),'@ALERTDAY',121),120)) = 2
THEN 'BUSINESS DAY IS' + datename(dw,"BUSINESS_DAY")
END
FROM [US_AML_APP].[dbo].[SAM_APP_USER_PROCESS] WHERE
[PROCESS_NAME]='AML_SAM_dailyProcess') IS NULL )
RAISERROR('DATE CHECK FAILED',11,1)
ELSE
RAISERROR('DATE CHECK PASSED',12,2)
RETURN
当我尝试传递像这样的参数时
exec AML_DATECHECK @ALERTDAY='2015-11-23'
失败了。
我还尝试了所有日期格式,例如2015/23/11,并尝试提供所有数据类型,但执行失败了:
从字符转换日期和/或时间时转换失败 字符串。
有人可以帮助我吗?