I need to fetch all names ends with a % at the end.
My query is working but don't know how:-
1. select name from table where name like '%\%%'
2. select name from table where name like '%%\%'
What you are confused about is the
% as a wildcard. It can match any number of characters -- or none.
So, you want:
where name like '%\%'
The two wildcards together (
%%) are the same as one. The first version will match something with
% in the middle of the string.
where right(name, 1) = '%' -- less confusing