In SQL , sometimes it is needed to use Single Quote in Strings and it comes rather confusing for new users in managing that ordeal.
In this article we will focus on how can we use single quote in strings.
How to escape single quote (‘) ?
In SQL, if you want to use single quote(‘) in a string , you can escape it using another single quote. This can be done by doubling the single quote.
SELECT 'This is Sam''s car.' AS Result;
You can also use them with SQL LIKE operators
SELECT * FROM demo_tab WHERE col LIKE 'That''s how you escape single quotes' ;
Different databases uses different mechanism for dealing with single quotes but the above syntax works with most of them.
Some database systems use ESCAPE keyword to escape single quotes but those database are not commonly used by much people.
Source: Microsoft documentation
Read More : SQL Window Function