请教:如何将字符型数据转换为数字,例如将字符123.78转换为数字123.78,转换前后要保持内容一致。

解决方案 »

  1.   

    select convert(numeric(10,2), '123.78')
      

  2.   

    select convert(numeric(10,2), '123.78')
    select cast('123.78' as numeric(10,2))
      

  3.   

    转换数据的函数 convert与cast
      

  4.   

    如果要修改字段类型的话用
    alter table 表名 alter column 字段名
      

  5.   

    declare @t varchar(10)
    set @t='123.78'select cast(@t as float)select cast(@t as decimal(18,2))