Escaping Single Quotes in MS SQL Server (T-SQL)

Tim Barsness

Escaping single quotes (‘) in Transact-SQL is done by replacing the single quote with two single quotes. So:

SELECT 'I went to Kinko''s'

Returns “I went to Kinko’s”

The only case where two consecutive single quotes don’t return a single quote is when the first one also starts the string.  In this case, if only two single quotes are present, the second one ends the string and the return value is the empty string.  SQL Blog Casts has a good example of this.

Doing the same in MySQL

Escaping a single quote in MySQL is done by adding a backslash before it (\’)

SELECT 'I went to Kinko\'s'

Last updated by on .

2 thoughts on "Escaping Single Quotes in MS SQL Server (T-SQL)"

  1. With appliances that run all the time, like your refrigerator, this can add up to big savings on your utility bills at the end of the year.
    Its 1,210-watt output is good enough to handle most commercial needs,
    and the dimensions of this handy coffeemaker are about 11.

    These ovens have become a necessity in today’s busy life as cooking with this appliance does
    not need a continuous supervision, when in the process of re-heating or coking food.
    More individuals are straying far from vast business style apparatuses, and rather picking stoves and ice chests that mix
    in with whatever is left of the kitchen. Stay Indoors
    and be entertained – for free or low cost: Go to the mall and window
    shop, sit in comfy chairs and play with handheld games, socialize with
    your friends or read a book.

  2. hermes bags outlet store fake hermes paris bag thailand jmnhxvybwx

What Are Your Thoughts?

Your email address will not be published. Required fields are marked *