May 15, 2015

To escape a single quote in Sql Server, use two single quotes. Note, don't use a double quote.

For example, the following SQL Script will give error.

  1. UPDATE Database.Name
  2. SET EmailTemplate = 'Don't Use a double quote. Instead use two single quotes'
  3. WHERE TemplateId = 1


Error: 105 Unclosed quotation mark after the character string '

To fix the error mentioned above, escape single quotes with two single quotes as displayed in following example.

  1. UPDATE Database.Name
  2. SET EmailTemplate = 'Don''t Use a double quote. Instead use two single quotes'
  3. WHERE TemplateId = 1

0 comments:

Reference: Shahed Kazi at AspNetify.com