apostrophe pb in SQL server

  • hello,

    I have problem when I send a request seeking a field containing an apostrophe.

    eg:

    I have a table Document containing Title field, then this field contains the string: it's Sabra and Chatilla

    I send this query to the server:

    SELECT * FROM Document WHERE Title='it''s Sabra and Chatilla'

    but it does nothing. I am sure it is the apostrophe that produces this result because I have done extensive testing to be sure

    do you now a solution for that?.

    help me please.

  • The following works:

    create table #Document (Title varchar(64))

    insert into #Document

    select 'it''s Sabra and Chatilla'

    SELECT * FROM #Document

    WHERE Title='it''s Sabra and Chatilla'

    drop table #Document

    You mention the Title field "contains" this string, what if you run this:

    SELECT * FROM #Document

    WHERE Title like '%it''s Sabra and Chatilla%'

    - Jeff

  • it does no result no error.

    i can't no why it happends

  • Maybe run something simpler like:

    SELECT Title FROM Document WHERE TITLE LIKE '%Sabra%'

    and if that doesn't return anything, run this just to confirm you have something there at all:

    SELECT Title FROM Document

    - Jeff

  • this query give a result

    SELECT Title FROM Document WHERE TITLE LIKE '%Sabra%'

    i have a title like it's Sabra and Chatilla .

    i want to search with complete title. but it dosen't work. no result found. i don't know how to find soluion at this prob.

  • you're mis-spelling the title in your query somehow. make sure it is exactly what it is in the database, that there are no hidden characters in the field and, if your collation is case sensitive that you have the correct case

  • also, verify that what you're calling an apostrophe is character 39 (') and not 96 (`)

  • i found a space at the end of title. apostrophe is 39(').

    but when i did upper(TitreDoc) = upper('C''était hier sabra et chatila').

    it doesn't work, no result. i think that the é which cause the pb.

    if i erase the upper function the query give result.

  • i found a space at the end of title. apostrophe is 39(').

    but when i did upper(TitreDoc) = upper('C''était hier sabra et chatila').

    it doesn't work, no result. i think that the é which cause the pb.

    if i erase the upper function the query give result.

  • i found a space at the end of title. apostrophe is 39(').

    but when i did upper(TitreDoc) = upper('C''était hier sabra et chatila').

    it doesn't work, no result. i think that the é which cause the pb.

    if i erase the upper function the query give result.

Viewing 10 posts - 1 through 9 (of 9 total)

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