How do I search for names with apostrophe in SQL Server?
Double them to escape;
SELECT *
FROM Header
WHERE userID LIKE '%''%'
SQL to Query text in access with an apostrophe in it
You escape '
by doubling it, so:
Select * from tblStudents where name like 'Daniel O''Neal'
Note that if you're accepting "Daniel O'Neal" from user input, the broken quotation is a serious security issue. You should always sanitize the string or use parametrized queries.
SQL 'LIKE' clause with apostrophe
This will work:
[Team] LIKE '%RYAN''S TEAM%'
You just have to double the quote chars.
How to I search for a single quote character( ' ) in a text Using LIKE predicate in SQL Server
CREATE TABLE #TEST
( Test_Column VARCHAR(MAX));
INSERT INTO #TEST VALUES
('10011-RIO MARE EXTRA''')
SELECT *
FROM #TEST
WHERE Test_Column LIKE '%''%'
The escape character for ' is ' used twice -> ''.
How to use apostrophe in LIKE operator on a WHERE clause? Example - WHERE WORD like '%That's why%'
WHERE WORD like '%That''s why%'
Example (SQL Server):
Related Topics
How to Replace a Substring of a String Before a Specific Character
How to Treat a Union Query as a Sub Query
Why Doesn't Oracle Allow Consecutive Newline Characters in Commands
Replacing Variable Length String with Some Word
How to Execute Different Select Statements Based on a Case
How to Get Id of Newly Inserted Record Using Excel Vba
How to Get Get Unique Records Based on Multiple Columns from a Table
How to Use Many Like Operators and Use Index
Working of Merge in SAS (With In=)
How to Execute SQL Statements in Command Prompt (Cmd)
Oracle 11G: Unpivot Multiple Columns and Include Column Name
Round Date to 10 Minutes Interval
Oracle Text Escaping with Curly Braces and Wildcards
Sql Query - Limiting Query Results