Can an single quotation mark/apostrophe ( ' ) be used in a literal string used in an expression?
Yes. This can be done using the ASCII value (39) for an apostrophe with the CHR function with the concatenation function ( || ) as follows:
|| CHR(39) ||
Source data as follows:
Problem: How do you use the IIF function to compare the "don't" string when it contains an apostrophe. The following expression will not work:
IIF (INPUT_STRING='don't call', RESULT1,RESULT2)
Solution: The following tests where the INPUT_STRING contains the word "don't":
IIF (INPUT_STRING='don' || CHR(39) || 't', RESULT1,RESULT2)
The input is:
The output should be:
Problem: How do you write a string with 'Hello World' using the single quotes as a literal in an expression?
Solution: The following returns the literal phrase 'Hello World':