我有下面列出的变量和CASE语句,但我收到此错误:
转换varchar值时转换失败' 2017-06-04 00:00:00.000'数据类型int。
知道我在这里做错了什么吗?我没有看到我使用INT数据类型的任何地方。
提前致谢
DECLARE @Week_# NVARCHAR(50)
SET @Week_# = '49'
DECLARE @Week_#Mapped NVARCHAR(50)
SET @Week_#Mapped =
CASE
WHEN @Week_# = '1' THEN '2016-07-03 00:00:00.000'
WHEN @Week_# = '2' THEN '2016-07-10 00:00:00.000'
WHEN @Week_# = '3' THEN '2016-07-17 00:00:00.000'
WHEN @Week_# = '4' THEN '2016-07-24 00:00:00.000'
WHEN @Week_# = '5' THEN '2016-07-31 00:00:00.000'
WHEN @Week_# = '6' THEN '2016-08-07 00:00:00.000'
WHEN @Week_# = '7' THEN '2016-08-14 00:00:00.000'
WHEN @Week_# = '8' THEN '2016-08-21 00:00:00.000'
WHEN @Week_# = '9' THEN '2016-08-28 00:00:00.000'
WHEN @Week_# = '10' THEN '2016-09-04 00:00:00.000'
WHEN @Week_# = '11' THEN '2016-09-11 00:00:00.000'
WHEN @Week_# = '12' THEN '2016-09-18 00:00:00.000'
WHEN @Week_# = '13' THEN '2016-09-25 00:00:00.000'
WHEN @Week_# = '14' THEN '2016-10-02 00:00:00.000'
WHEN @Week_# = '15' THEN '2016-10-09 00:00:00.000'
WHEN @Week_# = '16' THEN '2016-10-16 00:00:00.000'
WHEN @Week_# = '17' THEN '2016-10-23 00:00:00.000'
WHEN @Week_# = '18' THEN '2016-10-30 00:00:00.000'
WHEN @Week_# = '19' THEN '2016-11-06 00:00:00.000'
WHEN @Week_# = '20' THEN '2016-11-13 00:00:00.000'
WHEN @Week_# = '21' THEN '2016-11-20 00:00:00.000'
WHEN @Week_# = '22' THEN '2016-11-27 00:00:00.000'
WHEN @Week_# = '23' THEN '2016-12-04 00:00:00.000'
WHEN @Week_# = '24' THEN '2016-12-11 00:00:00.000'
WHEN @Week_# = '25' THEN '2016-12-18 00:00:00.000'
WHEN @Week_# = '26' THEN '2016-12-25 00:00:00.000'
WHEN @Week_# = '27' THEN '2017-01-01 00:00:00.000'
WHEN @Week_# = '28' THEN '2017-01-08 00:00:00.000'
WHEN @Week_# = '29' THEN '2017-01-15 00:00:00.000'
WHEN @Week_# = '30' THEN '2017-01-22 00:00:00.000'
WHEN @Week_# = '31' THEN '2017-01-29 00:00:00.000'
WHEN @Week_# = '32' THEN '2017-02-05 00:00:00.000'
WHEN @Week_# = '33' THEN '2017-02-12 00:00:00.000'
WHEN @Week_# = '34' THEN '2017-02-19 00:00:00.000'
WHEN @Week_# = '35' THEN '2017-02-26 00:00:00.000'
WHEN @Week_# = '36' THEN '2017-03-05 00:00:00.000'
WHEN @Week_# = '37' THEN '2017-03-12 00:00:00.000'
WHEN @Week_# = '38' THEN '2017-03-19 00:00:00.000'
WHEN @Week_# = '39' THEN '2017-03-26 00:00:00.000'
WHEN @Week_# = '40' THEN '2017-04-02 00:00:00.000'
WHEN @Week_# = '41' THEN '2017-04-09 00:00:00.000'
WHEN @Week_# = '42' THEN '2017-04-16 00:00:00.000'
WHEN @Week_# = '43' THEN '2017-04-23 00:00:00.000'
WHEN @Week_# = '44' THEN '2017-04-30 00:00:00.000'
WHEN @Week_# = '45' THEN '2017-05-07 00:00:00.000'
WHEN @Week_# = '46' THEN '2017-05-14 00:00:00.000'
WHEN @Week_# = '47' THEN '2017-05-21 00:00:00.000'
WHEN @Week_# = '48' THEN '2017-05-28 00:00:00.000'
WHEN @Week_# = '49' THEN '2017-06-04 00:00:00.000'
WHEN @Week_# = '50' THEN '2017-06-11 00:00:00.000'
WHEN @Week_# = '51' THEN '2017-06-18 00:00:00.000'
WHEN @Week_# = '52' THEN '2017-06-25 00:00:00.000'
ELSE 0
END
答案 0 :(得分:1)
底部是0。应该是文本默认值。