表T有一列weight
数据类型为nvarchar(60)
里面的数据想这样:
3.57
17.935
5.4kg
2斤
6.23
我现在要把那些不为数值的查询出来,咋弄啊? 

解决方案 »

  1.   

    select weight
    from T
    where isnumeric(weight)=0
      

  2.   

    -- =========================================
    -- -----------t_mac 小编-------------
       ---希望有天成为大虾---- 
    -- =========================================IF OBJECT_ID('tb') IS NOT NULL
      DROP TABLE tb
    GO
    CREATE TABLE tb(a varchar(10))
    go
    insert into tb
    select  
    '3.57' union all select 
    '17.935' union all select 
    '5.4kg' union all select 
    '2斤' union all select 
    '6.23' 
    go
    select a
    from tb
    where right(a,1) not like'[0-9]'
    /*------------
    a
    ----------
    5.4kg
    2斤-------*/
      

  3.   


    up
    if object_id('t') is not null drop table t
    create table t(id int,date1 datetime,sj varchar(10))
    insert into t select 1, '2009-05-10 00:00:00.000', 'gg'union all 
    select 2 ,'2009-06-15 00:00:00.000' ,'12' union all 
    select 3 ,'2009-06-04 00:00:00.000' ,'43kg' union all 
    select 3 ,'2009-06-04 00:00:00.000' ,'55'  union all 
    select 5 ,'2009-06-04 00:00:00.000' ,'43公斤'
    --测试数据
    select sj from t where isnumeric(sj)=0/*sj
    ----------
    gg
    43kg
    43公斤(3 行受影响)
    */