如果表a中的 字段p(字符型) 
        
A-769954
1-978663
.....类似的第一位是数字则选出来select * from a where ?????????如果直接用substring会类型错误哦

解决方案 »

  1.   

    select * from tablename where left(p,1) in ('0','1','2','3','4','5','6','7','8','9')
      

  2.   

    create table #temp
    (aa varchar(50))insert into #temp
    select 'A-1234'
    union all
    select 'B-1234'
    union all
    select '2-1234'
    union all
    select '3-1234'select * from #temp where left(aa,1) between '0' and '9'-----
    aa2-1234
    3-1234
      

  3.   

    create table T(p varchar(10))   
    insert T select 'A-769954'
    insert T select '1-978663'select * from T where substring(p, 1, 1) in ('0','1','2','3','4','5','6','7','8','9')
      

  4.   

    USE TestDB
    GO
    CREATE TABLE test
    (ID char(1),
     theName varchar(10))
    INSERT INTO test(ID,theName) VALUES('A','1adkfa')
    INSERT INTO test(ID,theName) VALUES('B','1adfdddkfa')
    INSERT INTO test(ID,theName) VALUES('C','aadkfa')SELECT * 
    FROM test 
    WHERE substring(theName,1,1)>='0' AND substring(theName,1,1)<='9'
      

  5.   

    select * from a where left(列名,1) like [0-9]