Link to home
Start Free TrialLog in
Avatar of RUA Volunteer2?
RUA Volunteer2?Flag for United States of America

asked on

When declaring a parameter in SQL Can you set the parameter to use all records that contain the word...

When declaring a parameter in SQL Can you set the parameter to use all records that contain the words like this '%Test%' or '%Experiment%' or '%Study%' so as an example can you do this?
   ALTER procedure [dbo].[bi_medica_code_combo]
        @med_code  ........... varchar(max) like  '%Test%' or '%Experiment%' or '%Study%'

Can you apply any record that contains those 3 values through to the parameter to run EXEC on the [bi_medica_code_combo]  procedure. If so I really need the proper format to make this work.
      @med_code  ........... varchar(max) like  '%Test%' or '%Experiment%' or '%Study%'
or
      @med_code  ........... varchar(max) "in" or "=" ... ('%Test%' , '%Experiment%' , '%Study%')

If I have to put the exact value like "Test1,Test2,Test3...Test100" to pass to the parameter and I cannot use some kind of '%...%' please let me know. 
SOLUTION
Avatar of Andrei Fomitchev
Andrei Fomitchev
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RUA Volunteer2?

ASKER

I am going to ask a stupid question here probably. Are those 3 options or three steps that I would have to apply I have to put inside of a declare statement. All I want is to declare the value of the parameter are you saying I have to put all that into the declare statement.
ALTER procedure [dbo].[bi_medica_code_combo]
(
      @start_date.......date = '20210501'
      @end_date........date = '20210601'
      @med_code.......varchar(max) = (are you saying to put all you posted above my existing query or part of it?)
      @insur_code......varchar(max) like ('%Blue%','%United%',''%Humana%') This line is formatted incorrectly to.
)
I have all my select from where and order by query below this declare section of the SQL?

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial