declare @d varchar
set @d = 'No filter'
if (@d like 'No filter')
BEGIN
select 'matched'
end
else
begin
select 'not matched'
end
the result of above is always not matched can anybody tell me why and how can I use the like or '=' result in my stored procedure. thanks
3条答案
按热度按时间gwbalxhn1#
Change your declaration to
Then
will work.
Please remember that LIKE is used for pattern matching,
something like
So in your case you might want to change the code to
with an "="
cclgggtu2#
You need to declare d as varchar(100) not just varchar, otherwise it just becomes N
Should be:
Also no need to use LIKE with this you can use =.
klsxnrf13#
I find
like
operator very useful.can be replaced
by only one line which is