对数据类型而言运算符无效。运算符为 subtract,类型为 nvarchar。   我现在用的 NVARCHAR  但是我想把两个数相减   我应该改成什么数据类型最好

解决方案 »

  1.   

    因为现在表已经导进去了 用的nvarchar  改成numeric  说改不了   
      

  2.   

    cast(col as decimal(18,2))
    cast(col as int)
      

  3.   

     subtract,不是sqlselect cast(字段 as int)-cast(字段 as int)
      

  4.   

    selec 列 from 表 where  isnumeric(列) = 0 
    找出不能转换的数据,查看是否包含全角,非数字字符等。
    还有就是replace(列,' ','')去空格。
      

  5.   

    select * from temp1 cast(读数 as decimal(18,2))   这样吗?
    提示 AS 附近有错误
      

  6.   

    select cast(大字段 as int)-cast(小字段 as int) from temp1
    select cast(大字段 as decimal(18,2))-cast(小字段 as decimal(18,2)) from temp1
      

  7.   

    ODBC 错误: [Microsoft][ODBC SQL Server Driver][SQL Server]将数据类型 nvarchar 转换为 numeric 时出错。那天强制转都还行 !!  今天怎么就不行了
      

  8.   

    declare @tb table (name varchar(10))
    insert into @tb select null
    insert into @tb select '123'
    insert into @tb select 'a1'
    select cast(name as decimal(18,2)) from @tb 消息 8114,级别 16,状态 5,第 8 行
    从数据类型 varchar 转换为 numeric 时出错。
      

  9.   

    declare @tb table (name varchar(10))
    insert into @tb select null
    insert into @tb select '123'
    insert into @tb select 'a1'select * from @tb 
    where isnumeric(name)=0NULL
    a1用这个查一下,看有转换错误的没