表中字段A的属性为nvarchar型
里面的数据都是91,203,182这种格式的内容;
这时候要按一个数字作为条件来查询;
如:select * From table where A>91203000
这段查询语句要怎么过滤掉"91,203,182"中的,号呢?

解决方案 »

  1.   

    select * From table where cast(replace(A,',','') as bigint)>91203000
    ---这个意思吗?
      

  2.   

    select * From table where replace(A,',','')>91203000
      

  3.   

    select * From table where replace(A,',','')>91203000
      

  4.   

    select * From table where cast(replace(A,',','') as bigint)>91203000
      

  5.   

    declare @t table([str] varchar(100))
    insert into @t select '91,203,182'select * From @t where replace([str],',','')>'91203000'
    --这样?
      

  6.   

    ---------
    select * from table where cast(replace(A,",",'') as int)>91203000
      

  7.   

    select * From table where cast(replace(A,',','') as bigint)>91203000
      

  8.   

    谢谢各位.不过会出错的啊
    服务器: 消息 8114,级别 16,状态 5,行 1
    将数据类型 nvarchar 转换为 bigint 时出错。
      

  9.   

    nvarchar-->bigint
     用CONVERT試試
      

  10.   

    谢谢各位了,
    select * From table where cast(replace(A,',','') As float) > 91203000