如下表T,有两个字段A和B。
A B
-----------
1 110010
2 111
3 11111
4 11011111
5 1
6 1111000111SQL语句:
select * from t where b ..........结果:
A B
----------
2 111
3 11111
5 1

解决方案 »

  1.   

    select * from t where charindex('0',B)=0
      

  2.   

    如下表T,有两个字段A和B。
    A B
    -----------
    1 1101235010
    2 111
    3 11111
    4 1111122211
    5 1
    6 1111000113334546171SQL语句:
    select * from t where b ..........结果:
    A B
    ----------
    2 111
    3 11111
    5 1 
      

  3.   

    where charindex('0',B)=0
    接个分~
      

  4.   

    select * from t where LEN(REPLACE(CONVERT(VARCHAR(50),B),'1',''))=0
      

  5.   


    declare @tb table(A int,B int)
    insert into @tb select 1,110010
          union all select 2,111
          union all select 3,11111
          union all select 4,1101111
          union all select 5,1
          union all select 6,111000111
     select * from @tb where b not like '%0%'
    (6 行受影响)
    A           B
    ----------- -----------
    2           111
    3           11111
    5           1(3 行受影响)
      

  6.   


    declare @table table (A int,B bigint)
    insert into @table
    select 1,1101235010 union all
    select 2,111 union all
    select 3,11111 union all
    select 4,1111122211 union all
    select 5,1 union all
    select 6,1111000113334546171select * from @table where len(replace(B,'1',''))=0 /*
    A           B
    ----------- --------------------
    2           111
    3           11111
    5           1
    */
      

  7.   

    SELECT B from table where len(B)-len(replace(B,'1',''))=len(B)
      

  8.   

    declare @tb table(A int,B nvarchar(20))
    insert into @tb 
    select 1,'110010' union all
    select 2,'111' union all
    select 3,'11111' union all
    select 4,'1101111' union all
    select 5,'1' union all
    select 6,'1110001' union all
    select 7,'00000'  select * from @tb where replace(B,left(B,1),'')=''A           B
    ----------- --------------------
    2           111
    3           11111
    5           1
    7           00000(4 行受影响)