Reputation: 273
I would like to write the following as a CASE
statement in my WHERE
clause, but I'm unsure how to write it.
if @Result = '' then
[Result] = @Result
else
[Result] like @Result + '%'
endif
Upvotes: 2
Views: 18060
Reputation: 11755
Try this. This is what exactly same as your if else
statement
WHERE [Result] LIKE (CASE @Result WHEN '' THEN @Result ELSE @Result + '%' END)
Upvotes: 0
Reputation: 43974
Something like this would work.
Declare @Result varchar(100)
Set @Result =''
Select *
From dbo.TABLE
Where [Result] Like Case
When @Result = '' Then @Result
Else @result + '%'
End
Upvotes: 4