Check If A String in Sql
SQL provide CHARINDEX() function Or LIKE Predicate to check if the string contains a specific substring
CHARINDEX() function
used to find a certain word or substring within a larger text and returns the first match it found.
It will return 0 if no words are detected (zero).
LIKE Predicate
You can search within a string or content for a substring using the LIKE predicate operator.
The LIKE operator in SQL Server is used to search for character string with the specified pattern using wildcards in the column.
Using ‘%’ wildcard, before, after or both side of character.
The WHERE clause of SELECT, UPDATE, and DELETE queries can also use this LIKE technique.
Understanding the WildCard Characters:
You can use the following wildcard characters with the LIKE operator in SQL Server.
% symbol represents any no of characters in the expression.
_ will represent a single character in the expression.
The [] symbol indicates a set of characters in the expression.
[^] will represent any single character, not within the specified range