search for ' in string column

  • I have one varchar(string) column.

    I want to query that column for character ' (char(39)).

    like

    select name from address where name like '%'%'

  • You just need to double up the single quotation mark:

    select name from address where name like '%''%'

    Mike

  • ok thanks .

    I have also one more requirement.

    I also want to search white spaces excluding a single space

    like TAB,line brake,new line character.

  • Try one of these:

    if searching for a tab

    select name from address where name like '%' + CHAR(9) + '%'

    or

    select name from address where CHARINDEX(CHAR(9),name) > 0

    Please also be aware that searches like these will table scan.

    Mike

Viewing 4 posts - 1 through 3 (of 3 total)

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