how to check an exsiting string using ms sql server function

  • I would like to check an exisitng in the data column.

    Example :

    Name :

    AHAH

    Woha we

    Select * From table name where NAme = instr(Name ,'HA')

    How to do it in SQL server.I select those Name contain an "HA" string

     

  • Works will try to use index, but with beginning wildcard, it will be inefficient.

    Select * From table name where NAme like '%HA%'

    Or

    -- Should work but will probably not use any index if it exists

    Select * From table name where patindex('%HA%',NAme) > 0

    Or

    Same problem with indexes

    Select * From table name where Charindex('HA',NAme) > 0

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply