Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I search for names with apostrophe in SQL Server?

SELECT *   FROM Header  WHERE (userID LIKE [%'%]) 
like image 734
Ontonomo Avatar asked Jun 28 '11 15:06

Ontonomo


People also ask

What is %s in SQL query?

%s is a placeholder used in functions like sprintf. Check the manual for other possible placeholders. $sql = sprintf($sql, "Test"); This would replace %s with the string "Test".

How do I find a character in a string in SQL?

SQL Server CHARINDEX() Function The CHARINDEX() function searches for a substring in a string, and returns the position. If the substring is not found, this function returns 0. Note: This function performs a case-insensitive search.

How do you count comma separated values in a single cell in SQL?

SQL Pattern: How can I count the number of comma separated values in a string? Basically, you replace all occurrences of , with an empty string "" , then subtract its LENGTH from the LENGTH of the unadulterated string, which gives you the number of , characters.


2 Answers

Double them to escape;

SELECT *   FROM Header  WHERE userID LIKE '%''%' 
like image 90
Alex K. Avatar answered Sep 19 '22 05:09

Alex K.


SELECT     * FROM Header WHERE (userID LIKE '%''%') 
like image 30
codingbadger Avatar answered Sep 20 '22 05:09

codingbadger