Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Array for Values Help

Author  Topic 

tmcrouse
Starting Member

12 Posts

Posted - 2014-10-24 : 10:46:52
I am used to using SAS when I run any extraction or query. I use a %let statement to store values. Example:

%let MID = ('1111', '2222', '33333', '4444');

This is helpful because at times I might have 500 memberID's or TaxID's. In this case I am trying to do it with 3446 memberID's

I want to know how to do the same in SQL? How to store my 3446 in a statement and then in my where just have it as:

where MCID in &MID.

That is how we do it in SAS anyway.

tmc

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-10-24 : 11:46:02
In SQL, the best way is to store your memberIDs into a table (temporary or virtual) and join to that table. So instead of WHERE MCID in &MID, you would do:
....
FROM
YourOtherTable t
INNER JOIN YourTempTaleWithMemberIds m on m.MCID = t.MCID
Go to Top of Page
   

- Advertisement -