select * from table where price > '100'这样就不会错,但是会连大于100的也查出来了。。

解决方案 »

  1.   

    --非0-9以及中文字符之外的字符删除建立如下函数
    create function getnewstr
    (@oldstr varchar(100))
    returns varchar(100)
    as
    begin
    declare @i int
    set @i = 1
    while @i <= len(@oldstr)
    if substring(@oldstr, @i, 1) like('[^0-9]')
    set @oldstr = replace(@oldstr, substring(@oldstr, @i, 1), '')
    else
    set @i = @i +1
    return @oldstr
    end
    goselect * from tb where price like ('%[^0-9]%') and cast(dbo.getnewstr(price) as int) > 60 
      

  2.   


    你这个把'100'当字符串了。。'60..' > '100'的呀建议你自己写个函数,然后把'60..'转成你要的int型
      

  3.   

    --非0-9以及中文字符之外的字符删除 建立如下函数 
    create function getnewstr 
    (@oldstr varchar(100)) 
    returns varchar(100) 
    as 
    begin 
    declare @i int 
    set @i = 1 
    while @i  <= len(@oldstr) 
    if substring(@oldstr, @i, 1) like('[^0-9]') 
    set @oldstr = replace(@oldstr, substring(@oldstr, @i, 1), '') 
    else 
    set @i = @i +1 
    return @oldstr 
    end 
    go select * from tb where price like ('%[^0-9]%') and cast(dbo.getnewstr(price) as int) > 60  
    对了...select * from tb where price not like ('%[^0-9]%') and cast(dbo.getnewstr(price) as int) > 60  
    这样就完全对了.
    谢谢...
    现在结不了贴...