Need To Find ''s

  • I need to use the like statement to find  's (Apostrophe)

     

    But because the LIKE I need to put it between two apostrophes’s it does it does not recognize the sting I’m trying to find.

     

    Any help would be great.

  • Select * from dbo.MyTable where MyField like '%''%'

  • You can also use:

    SELECT * FROM dbo.MyTable WHERE MyField LIKE '[']s%'

    or you can always use the ASCII character:

    SELECT * FROM dbo.MyTable WHERE MyField LIKE CHAR(39) + 's%'

     

    I wasn't born stupid - I had to study.

  • if u need to find an apostrophe ['] in a string, u'll have to escape it with another apostrophe. That's exactly what Remi did in his post's code line.

    Ccnversely. if u need to insert an apostrophe into a SQL table, say using ADO.NET, u'll have to substitute each ['] in your insert statement for ['']. Otherwise SQL Sever will report an error.

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

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