表中 有字段 A  B  C 数据类型都是VarChar型的
我现在要用update 语句计算A=B-C应该如何转换数据类型呢!!

解决方案 »

  1.   

    convert (int , b )-convert (int , c )orcast ( b as int   ) - cast ( c as int  )
      

  2.   

    update a=cast(b as int)-cast(c as int)
      

  3.   

    update biaomimg set  A=convert(int, b)-convert(int,c)
      

  4.   

    convert是sql server专用的函数
    cast其它的数据库也可用
      

  5.   

    先convert或者cast转换下数据,然后再计算。
      

  6.   

    update a=str(cast(b as int)-cast(c as int))
      

  7.   

    个人 喜欢用 cast(a as 类型)
      

  8.   


    update tb set a=cast(b as int)-cast(c as int)