>Hello,
>I'm using a variable in the WHERE clause of a SQL Statement. The variable looks like so:
>cMyVar = "ALLTRIM(MyTable.MyField) = '" + ALLTRIM(THIS.VALUE) + "'"
>
>Naturally, if MyTable.MyField contains an apostroph (like "De'Isle"), I get a syntax error :-(
>What do I have to do in this case?
You might try using the square brackets
[] as delimiters within the string rather than the apostrophe, since they don't occur in the typical data; IOW:
cMyVar = "ALLTRIM(MyTable.MyField) = [" + ALLTRIM(THIS.VALUE) + "]"
Also, you're hurting yourself needlessly using ALLTRIM() in WHERE clauses; it ensures that the expression will not be Rushmore-optimizable, and depending on the SET environment, may result in unexpected matches using the
= operator.
>Thanks in advance for your help!