Wednesday, January 15, 2025
HomeProgrammingHow do I Escape a Single Quote in SQL Server?

How do I Escape a Single Quote in SQL Server?

In SQL Server, to escape a single quote (‘) within a string literal, you typically use two single quotes in a row (”). Here’s how it works:

If you have a string like O’Connor, you would write it in SQL as O”Connor.

See also  JavaScript’s set Attribute() Method

So, your SQL query might look something like this:

sqlCopy code

SELECT * FROM Users WHERE LastName = ‘O”Connor’;

This tells SQL Server to interpret the two consecutive single quotes (”) as a single quote within the string literal.

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x