I would like to select the records that contain the content of the @selctDescription parameter but only when @selctDescription is not empty.
I have the following, which does not work:
(t.[description] LIKE
(
CASE
WHEN @selctDescription = '' THEN t.[description]
ELSE ('%' @selctDescription '%')
END
)
)
Can anyone point me in the right direction?
SELECT *
FROM Table
WHERE
((@selctDescription IS NULL OR @selctDescription = '')
OR
(t.[description] LIKE '%' + @selctDescription +'%'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With