473,563 Members | 2,797 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 5232
[posted and mailed, please reply in news]

(da********@yah oo.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****@sommarsk og.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
6981
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 it return the associated records to a listbox. Once the listbox has the records, I want to select a record, which will open a form associated with...
6
9639
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 made for service staff. My problem is the SQL is not retrieving the value of the listbox. I have tested the SQL by entering a fixed value of a...
3
2629
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 Object, ByVal e As System.EventArgs) Handles cmdsave.Click Dim command As New OdbcCommand Dim str As String Dim photo() As Byte =...
0
1688
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 convert parameter value from a SqlParameter to a String. Here is some code that works and does not work.
4
1324
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 code will do is if it is 'd' it will make a delete query template string. if it is an 'i' then insert query etc.
2
5415
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 stating, ENTER PARAMETER VALUE when I am generating a report. I know that the culprit lies in the query stored in the report. I have entered data in the...
1
5054
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 began getting the "Enter Parameter Value" dialog and it was asking for the query by its name "sel_report_data" whenever I tried to run or preview the...
3
2330
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 other choice? For example, def func(self, x, y, A, B, C): #x, y change in recursive call
0
7665
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6255
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.