我有一个表像和服务器是SQL Server 2008 R2中,我们不能使用concat
功能串接在SQL Server 2008 R2失败时monthid是2个位数
YearID | MonthId
--------+----------
2017 | 1
2014 | 5
2014 | 10
2016 | 12
我想有输出
201701
201405
201410
201612
我试了一下,到目前为止
select
cast(YearId as varchar(50)) + '0' + cast(MonthId as varchar(50))
from
TEST
我得到的输出作为
201701
201405
2014010
2016012
当monthID
是2位数字时,它失败。
如何解决这种情况?