473,499 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Parameter (@value) for "IN" function list

I am trying to select a group of records based on a parameter value
passed to the db from a web page. The value comes in as @Status and
has a list of statusID's: (1,2,5,9) I've tried to use
"Where table.status IN (Select * from @Status AS ValueList)"
And also tried
"Where table.status IN (@Status)"
And neither worked. Any suggestions?

Jul 20 '05 #1
2 5224
[posted and mailed, please reply in news]

(da********@yahoo.com) writes:
am trying to select a group of records based on a parameter value

passed to the db from a web page. The value comes in as @Status and
has a list of statusID's: (1,2,5,9) I've tried to use
"Where table.status IN (Select * from @Status AS ValueList)"
And also tried
"Where table.status IN (@Status)"
And neither worked. Any suggestions?


WHERE table.status IN (@status)

is equivalent to

WHERE table.status = @status

More generally

WHERE table.status IN (@val1, @val2, @val3)

is a short-cut for:

WHERE status = @val1 OR status = @val2 OR status = @val3

As for:

Where table.status IN (Select * from @Status AS ValueList)

In this case @status would need to be a table variable with on single
column. (And a table variable is variable of which the datatype is a
table.)

For actually do what you want to do, see a part in an article on my web
site: http://www.sommarskog.se/arrays-in-s...st-of-integers

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
Kind sir,
I was successful with this method of approach. Thank you very much
once again for your excellent help!

--Chris

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
6971
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have...
6
9620
by: Dave Hopper | last post by:
Hi I am using the following SQL to retrieve a value in a list box using a unique ID held in the list box call cntID. The list box is used on an order form to list appointments that have been...
3
2627
by: programmer2004 | last post by:
Hi, I am trying to pass parameter value to ODBCCommand object. but it is not assigning values , the null value is gets stored. i m using following code, Private Sub cmdsave_Click(ByVal sender As...
0
1680
by: Chris Crowe [MVP 1997 -> 2006] | last post by:
I am having major problems using GetStoredProcCommand and using Parameters in the same function call in the latest builds of the Enterprise Library Data. The error I get is : Failed to...
4
1314
by: 3rdshiftcoder | last post by:
hi- i am having trouble using parameter values in my function and to be honest a little trouble with member variables. i am trying to pass in the argument 'd' representing delete. what the...
2
5411
by: mudman04 | last post by:
Hi, I searched online for some similar issues that I am facing but was not able come up with anything. I am fairly new with Access (2 months experience) and I am trying to remove a message...
1
5039
by: waltnixon | last post by:
I've got an MS Access query which runs fine when double clicked and returns all of the rows in a test database I'm building. I've set up a multi group report based on the query. I immediately...
3
2324
by: Davy | last post by:
Hi all, Sometimes I need to pass same parameter in recursive function. From my point of view, the style is redundant, and I don't what to use some global style like self.A, self.B, Is there any...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7386
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.