SQL help

I need to get the all the row for the value 11 from the below table. Could you give me sql statement for this.


create table teststring(a varchar(25))

insert into teststring
values('11:02,05:BL')
insert into teststring
values('16:03,11:RS')
insert into teststring
values('13:01,04:LL')
insert into teststring
values('16:05,11:RS')

drop table teststring



Answer this question

SQL help

  • zombie_process

    Hi Guys,
    Your idea is correct but i feel this could be a positive way instead of <> you could use >

    select * from teststring where charindex('11',a)>0

    All the Best


  • MadAboutC#

    Sory Folks,
    The below ligic will work better  as I expected.

    select * from teststring where charindex('11',a)<>0

  • Bharati Kumars

    Or maybe:

    select * from teststring
    where a LIKE '%11%'



  • Michel Blairon

    Is this what you're after

    select * from teststring
    where (
        substring(a, 1, 2) = '11'
    or  substring(a, 4, 2) = '11'
    or  substring(a, 7, 2) = '11'
    )


    Clifford Dibble
    Program Manager, SQL Server


  • SQL help