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 2005 Forums
 Analysis Server and Reporting Services (2005)
 Dynamic Query with multi-value parameters

Author  Topic 

KY
Starting Member

1 Post

Posted - 2008-06-01 : 07:01:34
Is anybody here knowing how to create a dynamic query based on a multi-value parameter?

e.g. there is a multi-value report parameter called names. For a static query, the where clause of a select statement likes the following

select * from students where name=@names

For the dynamic one, I tried something like the below, but it did not work.

="select * from students where name=(" & Join(Parameters!names ,',') & ")"

Any suggestion would be great appreciated.



Thanks,
KY

Will Riley
Starting Member

10 Posts

Posted - 2008-06-01 : 12:45:25
Try

WHERE Name IN

as opposed to

WHERE Name =

Cheers,

Will
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-01 : 14:59:21
quote:
Originally posted by KY

Is anybody here knowing how to create a dynamic query based on a multi-value parameter?

e.g. there is a multi-value report parameter called names. For a static query, the where clause of a select statement likes the following

select * from students where name=@names

For the dynamic one, I tried something like the below, but it did not work.

="select * from students where name=(" & Join(Parameters!names ,',') & ")"

Any suggestion would be great appreciated.



Thanks,
KY


May be this

select * from students where ','+ Join(Parameters!names ,',')+',' LIKE '%,' + name + ',%'
Go to Top of Page
   

- Advertisement -