select case when cast(t_cw_bmmc_hsj.bbh as int) is null then 1 else cast(t_cw_bmmc_hsj.bbh as int)+1 end我这里有个数据表,有一个字段是BBH。怎样将这个字段转换为INT后 执行?
那位帮忙看看 ,急.......

解决方案 »

  1.   

    select case when isnumeric(t_cw_bmmc_hsj.bbh)= 0 then 1 else t_cw_bmmc_hsj.bbh+1 end 
      

  2.   

    select case when cast(t_cw_bmmc_hsj.bbh as int) is null then 1 else cast(t_cw_bmmc_hsj.bbh as int)+1 end 你想啊,如果t_cw_bmmc_hsj.bbh是null,那怎么转化成int啊,对不对。
    可以用1楼的函数吧,更科学
      

  3.   

    对了 忘了加个说明 我是从oracle数据库导入sql server数据库,因此肯定要把oracle变成sql的语法
    那位大哥 知道帮下忙 谢谢
      

  4.   

    select case when isnumeric (TB.CODE_ID) =0 then 1 else  TB.CODE_ID+1 end消息 4104,级别 16,状态 1,第 2 行
    无法绑定由多个部分组成的标识符 "TB.CODE_ID"。
    消息 4104,级别 16,状态 1,第 2 行
    无法绑定由多个部分组成的标识符 "TB.CODE_ID"。请教一下?