How do I escape a single quote in SQL Server

A single quote can be escaped by doubling them up in MSSQL server. There are many ways to escape a single quote in SQL server. Let us look at the below examples to find out more information.

Sample SQL Query to escape a single quote

The other alternate way would be to use the built-in method char(39) which also result in single quotes. Hence, while inserting the data into the table append the char(39) which MSSQL will decode and append the quotes into the data.

Even for the update statement and select statement same logic can be applied to escape the single quotes.

You may also like...

Leave a Reply

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