我尝试连接"年"和"月"变量。这些变量保持为整数类型。然而,"年"变量保持其
records ->"2015","2016"
和"月"变量保持其
records->"1","2","3","4","5","6","7","8","9","10","11","12".
我希望看到我想要的变量,例如->"201501","201502"
等。如何达到我想要的输出?
这是我的脚本 - >
Select CONVERT(DATE,TRIM(CONVERT(CHAR(4),YEAR)||(Case When MONTH<10 Then '0' || Convert(Char(2),MONTH) Else Convert(Char(2),MONTH) End ))) Into #New_Table1
From Table1
答案 0 :(得分:0)
解决这个问题的方法很多:将你的第一个'CHAR(2)'变为'CHAR(1)'