selecting values with apostrophe RRS feed

  • Question

  • User-1106823036 posted

    when searching for  a certain name, the SQL command is throwing error if the name includes apostrophe.

    this is my query

    SELECT * FROM [Active_Authors] where  Author_En like '%" & search & "%' "

    but the search variable might be xxx or xx'x

    the first search (xxx) is working fine

    but the second search(xx'x) is throwing an error.

    How could that be fixed?

    Thank you in advance

    Wednesday, January 13, 2016 8:01 AM


  • User1401801381 posted



    SELECT * FROM [Active_Authors] where  Author_En like '%" & search.Replace("'","''") & "%' "

    (double the apostrophe)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 13, 2016 8:17 AM