How to escape single quote in SQL Server?

Today, when I was trying to insert a value to a table in SQL Server which had single quotes, I ended by getting the following error.

Unclosed quotation mark after the character string

The query looked like this


How to escape a single quote in SQL Server?

To fix the above error, we can escape the single quotes by doubling or inserting two single quotes as shown in the below query


If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

One Response

  1. Bevan Weiss August 8, 2013 Reply

Leave a Reply


Interesting BlogPosts to read

Column Alias and Square brackets in SQL Query.
When we want to specify a alias for a column in SQL Query , we tend to use the double quotes or sing...
How to get the MAX row with group by in LINQ query using C# ?
Below is a sample code snippet demonstrating how to retreive the max row with the group by in LINQ Q...
Webinar - The Shortcomings of SQL for SharePoint Sync
Redmond Magazine is hosting a webinar on the topic "The Shortcomings of SQL for SharePoint Sync" on ...