首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

为什么这个0加不上?解决方案

2012-01-11 
为什么这个0加不上?selectconcat(concat(YY, - ),casewhenMM 10thenconcat( 0 ,MM)elseMMend)fromsocial

为什么这个0加不上?
select   concat(concat(YY, '- '),case   when   MM < '10 '   then   concat( '0 ',MM)   else   MM   end   )   from   social.grantdetail;

显示都是2007-1

[解决办法]
Select Cast(YY As Varchar) + '- ' + Right(100 + Cast(MM As Int), 2) from social.grantdetail;

热点排行