SQL Declare

I have the following list of items I want to use in an " IN " statement and would like to declare them at the beginning.  What's the best way to handle this.

SET @APPTTYPE = '('BOTOX', 'CONSLT20', 'CONSLT30', 'CONSLT40', 'CONSLT50', 'CONSLT60', 'EMG/NCS', 'EN20', 'EN30', 'EN40', 'EN50',
                      'EN60', 'EO20', 'EO30', 'EO40', 'EO50', 'EO60', 'JNT INJ', 'MVA')'
Joel BrownIT DirectorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Data DudeCommented:
Ug  {dramatic pause for effect}  ly.

A better idea rather than dynamic SQL, and the increased risk of making a typo, would be to create a temp table (or even better a physical table) to store those values, then you can JOIN.
CREATE TABLE APPTTYPE (appttype varchar(100)) 

VALUES ('BOTOX'), ('CONSLT20'), ('CONSLT30'), ('you get the idea') 

Open in new window

Then in SQL use the below JOIN, which will filter on only those values in APPTTYPE.appttype
SELECT blah, blah, blah
FROM YourTable yt
   JOIN APPTTYPE at ON yt.whatever = at.appttype

Open in new window

Replace APPTTYPE with the temp table #appttype if that floats your boat.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.