我现在要查询  一列  可是只有年月 没有日   不知道怎么取了  哪位老大 帮忙解决哈??
比如201003  怎样取出里面的  3  这个月份  急急急急急急

解决方案 »

  1.   


    select right(col , 2) from tbselect cast(right(col , 2) as int) from tb
      

  2.   

    select cast(right(col , 2) as int) from tb
      

  3.   


    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
      

  4.   

    select cast(right(col , 2) as int) from tb
      

  5.   

    select cast(right(col , 2) as int) from tb
    select datepart(m,'201003' +'01')
      

  6.   

    cast(right('201003' , 2) as int)
      

  7.   

    这个数据应该不是日期格式,而是你自己存储的格式。,所以只能用截取一共12个月、、、、所以选择右侧两位、            right(字段,2) 如果小于10不想显示前面的0就做个判断,
                              if    right(字段,2)<10 then 值=right(字段,1)