Parameter for an IN clause

J

Joe Thompson

Hi,

I am using C# to write a windows app that uses a MS Access DB. I have a
query saved in Access (stored procedure) that has some parameters:

SELECT *
FROM Loans
WHERE (BranchName=[@bn] And DateFunded>=[@dfStart] And DateFunded<=[@dfStop]
And RepName IN ([@rns]));

My question is, how do I pass in a list of more than one name for @rns?

Something like ...RepName IN ('Eddie', 'Bill', 'Bob')...

Thank you,
Joe
 
J

Joe Thompson

Thanks for the info. It would be nice if it could be done...

Joe

Cor Ligthert said:
Hi Joe,

You simply cannot do that.

Cor


Joe Thompson said:
Hi,

I am using C# to write a windows app that uses a MS Access DB. I have a
query saved in Access (stored procedure) that has some parameters:

SELECT *
FROM Loans
WHERE (BranchName=[@bn] And DateFunded>=[@dfStart] And
DateFunded<=[@dfStop]
And RepName IN ([@rns]));

My question is, how do I pass in a list of more than one name for @rns?

Something like ...RepName IN ('Eddie', 'Bill', 'Bob')...

Thank you,
Joe
 
J

Joe Thompson

Hi Mark,

That's an interesting idea - thanks! Just out of curiosity, if it's not too
much work to explain, how would you do it in SQL Server?

Joe
 
W

William Vaughn \(MVP\)

There are several approaches to this problem in SQL Server including using
Table-type Parameters, CLR or TSQL routines that parse delimited strings
into Table variables and others.

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
http://betav.com http://betav.com/blog/billva
____________________________________________________________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top