From: bcap on
Is it possible to create a SQL In statement using variables?

For example, here is what can be done:

SELECT Test.ID, Test.Desc
FROM Test
WHERE (((Test.ID) In (3,6,9,12)));


But, I would like to do something like this:

SELECT Test.ID, Test.Desc
FROM Test
WHERE (((Test.ID) In ([@TestTypes])));

( I have a loop that will be passing the: 3,6,9,12 )

However, it does not work. Am I missing something in the syntax or is
it I cannot do it this way?

Any thoughts and or advice is greatly appreciated.

Ray



From: timmg on
You can pass a single parameter easiely - check help for details.

However, for your example it might make more sense to build the sql
statement as a text string and then execute it. Have your loop build
the IN statement and concatenate the parts as required.

Tim Mills-Groninger

On Jun 24, 10:34 am, bcap <r...(a)patriots.com> wrote:
> Is it possible to create a SQL In statement using variables?
>
> For example, here is what can be done:
>
> SELECT Test.ID, Test.Desc
> FROM Test
> WHERE (((Test.ID) In (3,6,9,12)));
>
> But, I would like to do something like this:
>
> SELECT Test.ID, Test.Desc
> FROM Test
> WHERE (((Test.ID) In ([@TestTypes])));
>
> ( I have a loop that will be passing the: 3,6,9,12 )
>
> However, it does not work.  Am I missing something in the syntax or is
> it I cannot do it this way?
>
> Any thoughts and or advice is greatly appreciated.
>
> Ray