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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Dynamic IN clause

Author  Topic 

GenSQL
Starting Member

14 Posts

Posted - 2002-03-18 : 12:10:32
I am passing an array through a parameter...
and need to use it for a dynamic IN clause

something like:

declare @test varchar

set @test = '1, 2, 7' -- valid but incorrect value
-- this resolves as a single expression, not a list of expressions


select * from catalogitem_t
where id IN (@test)


Any help would be a great!

rknewbow
Starting Member

7 Posts

Posted - 2002-03-18 : 12:21:11
Take a look at the FAQs. I think your problem will be solved there.

Go to Top of Page

JamesT
Yak Posting Veteran

97 Posts

Posted - 2002-03-18 : 12:41:02
Here's a head start:

declare @var varchar(10)
declare @stmt varchar(1000)

set @var = '(''A'',''B'')'
set @stmt = 'select * from foo where A IN ' + @var
exec(@stmt)

Go to Top of Page
   

- Advertisement -