How to escape a single quote in SQL Server?

  • How-Tos FAQs
  • February 1, 2019
Supercharge Your Snowflake SQL
with Datameer's
Data Transformation

The most simple way to escape a single quote in SQL Server is to pair it with another single quote.

Below are some examples:

-- For selecting: [My name's Jack.]
SELECT 'My name''s Jack.' escaping_quote

-- Output
escaping_quote
--------------------
My name's Jack.

-- For selecting: ['My name's Jack.']
SELECT '''My name''s Jack.''' escaping_quote

-- Output
escaping_quote
-------------------
'My name's Jack.'

Up Next:

Read How to get only the DATE part from the DATETIME in SQL Server

Related Posts

SQL FAQ Feat

How to avoid SQL injection in PHP?

  • How-Tos FAQs
  • December 15, 2018