select right(col , 2) from tbselect cast(right(col , 2) as int) from tb
select cast(right(col , 2) as int) from tb
create table table_Pqs(col char(6) not null); insert into table_Pqs select '201003';select cast(right(col,2) as int) from table_Pqs;drop table table_Pqs
select cast(right(col , 2) as int) from tb
select cast(right(col , 2) as int) from tb select datepart(m,'201003' +'01')
cast(right('201003' , 2) as int)
这个数据应该不是日期格式,而是你自己存储的格式。,所以只能用截取一共12个月、、、、所以选择右侧两位、 right(字段,2) 如果小于10不想显示前面的0就做个判断, if right(字段,2)<10 then 值=right(字段,1)
select right(col , 2) from tbselect cast(right(col , 2) as int) from tb
create table table_Pqs(col char(6) not null);
insert into table_Pqs select '201003';select cast(right(col,2) as int) from table_Pqs;drop table table_Pqs
select datepart(m,'201003' +'01')
if right(字段,2)<10 then 值=right(字段,1)