Hello experts,
I have a sql script here, that has a like portion of my where clause that is not behaving like I wish. Here it is:
/********************************
DECLARE @MEDNAME varchar(500)
DECLARE @MED char(200)
DECLARE @Found int
SET @MEDNAME = null
SET @MED= 'Actoplus MET'
select top 1 medication_name from patient_medication-- WITH (NOLOCK)
WHERE enterprise_id = '00001'
AND practice_id = '0001'
AND person_id = 'C0B99DCB-8080-471C-BE3F-79B8EB02EBF7'
and medication_name like '%' + @MED + '%' -- THIS LINE IN QUESTION
select @MED, @MEDNAME
*****************************/
When I include the medication_name piece of the w here clause, I get no returns. If I take it out I get:
Actoplus MET 15 mg-500 mg Tab -- based on the select top 1 medication name piece.
FOr some reason my
SET @MED= 'Actoplus MET'
doesnt play well with my
and medication_name like '%' + @MED + '%'
Thoughts?
Thanks!
SELECT 'Actoplus MET', null
That is suspicious to me because you are selecting literals instead of data from a table...