apostrophe in an IN statement - TSQL

Will Faulkner 201 Reputation points
2021-05-26T14:08:08.687+00:00

Hello

In an IN statement I need to add people's full names:

IN ('will faulkner', 'liz taylor', 'martin p'smith')

The final name - martin p'smith - throws up an error because of the apostrophe in the surname. I tried to get round it by:

'martin p"smith' but that didn't bring through any data.

any advice please on how I can add a name with an apostrophe in an IN statement would be appreciated.

Thanks

Developer technologies | Transact-SQL
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 122.6K Reputation points
    2021-05-26T14:11:50.01+00:00

    Use two apostrophes instead of quotation mark: 'martin p''smith'.

    Also note that there are more forms of apostrophes. Check that the table contains a simple one.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.