Page 1 of 1

SQL Update

Posted: Fri May 01, 2009 7:08 pm
by warrenk
I am having a issue with a SQL Update when my variable has a single quote in the data.

ie. tDescriptionReview = It's a fascinating book

...the single quote in "It's" is causing my update to fail since I am using single quotes to surround by text fields. How would I get around this?

Here is how I am updating...

put "UPDATE books set description = " & "'" & tDescriptionReview & "'" & " where id = " & tID into tSQL
revexecutesql gConID, tSQL

Thanks!
Warren

Posted: Fri May 01, 2009 7:44 pm
by Mark
Hi Warren,

Use the backslash to escape the single quote. You don't say which SQL flavour you use, but in the MySQL documentation, you'll find more information about escaping characters.

Best,

Mark

Posted: Sat May 02, 2009 3:15 pm
by warrenk
Thanks Mark...the backslash worked!

Warren