Results 1 to 2 of 2

Thread: Quick SQL query question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    Peterborough, Cambs, England
    Posts
    176

    Quick SQL query question

    Hi

    If I need to use an SQL query such as...

    SELECT * FROM client WHERE surname = " & cdata.surname & "%"

    ...what would be the correct syntax to use if the surname was O'Brien for instance.

    Any surname that has a ' in it causes a syntax error.

    Can someone help me please.

    Thanks

  2. #2
    nullus
    Guest

    Smile

    VB Code:
    1. SELECT * FROM client WHERE surname LIKE '" & Replace(cdata.surname, "'", "''") & "%'"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width