This article is half-done without your Comment! *** Please share your thoughts via Comment ***
Check the below input data and expected output to find all the records which contain percentage (%) character.
Input Data:
1 2 3 4 5 6 |
strvalue ---------- Anvesh% Anv%dbrnd Patel %Patel |
Expected Output:
1 2 3 4 5 |
strvalue ---------- Anvesh% Anv%dbrnd %Patel |
Create a table with data:
1 2 3 4 5 6 7 8 9 10 |
CREATE TABLE tbl_strings ( strvalue VARCHAR(10) ) GO INSERT INTO tbl_strings VALUES ('Anvesh%'),('Anv%dbrnd'),('Patel'),('%Patel') GO |
Solution 1: Using ESCAPE character
1 2 3 |
SELECT strvalue FROM tbl_strings WHERE strvalue LIKE '%\%%' ESCAPE '\' |
Solution 2: Using Square Brackets
1 2 3 |
SELECT strvalue FROM tbl_strings WHERE strvalue LIKE '%[%]%' |
Please try the different solution for this puzzle and share it via comment...