User Input Parameter for SQL Query

I need to create a very simple query.  I would like to return all the data from one table for a specific item.  I want the user to be prompted to enter the item id.  Below is an example of the query without letting my user enter the item.

Select * from inventory
where inventory.item_id = 'AQUA-12345'

I just want this to be generic so my user is prompted to enter the item they are looking for.
RDB1369Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BrandonGalderisiCommented:
I am assuming SQL 2000 based upon the tags.

You would pass a parameter in to a procedure.


create procedure up_inventory_get
 @item_ID varchar(30)
as
select * from inventory
where item_id = @item_id
go


to call it:

exec up_inventory_get @item_ID = 'AQUA-12345'
0
jamesguCommented:
from where do you run the query?

basically, you need to prompt to the user and get the input, and then bind the parameter in the below query

Select * from inventory
where item_id = ?

0
RDB1369Author Commented:
This is exactly what I have done so far, and yes you are right I am working in SQL 2000.  
However, I really wanted my user to be able to just exec the stored procedure and be asked the question  "Enter Item",   Is this possible?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

BrandonGalderisiCommented:
No.  
0
RDB1369Author Commented:
I am sorry I did not see the second comment when I posted my response.  I have written a procedure like Brandon suggested and I can use that, but I wanted to just have my user type in
          Exec Up_inventory_get
and then the first part of the procedure would prompt my user to enter the correct item ID.
0
jamesguCommented:
i don't think you can do that since stored procedure is server-side object,

what you may do is to create a .bat (if it's in windows environment) or a shell script to achieve that
0
BrandonGalderisiCommented:
I think it's time to close this question up.

You said you used a procedure like http:#22815829 and I answered your question about prompting for input in http:#22815907
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RDB1369Author Commented:
I guess this is as good as it gets
0
BrandonGalderisiCommented:
Why the B grade?  Unfortunately, you can't do what it is you are asking to do.  I answered your question completely and accurately.

I'd like you to reconsider the grade based upon the grading suggestions here (copied from help):

What's the right grade to give?

Grading at Experts Exchange is not like school. It's more like the "10-point Must" system in professional boxing; in other words, an answer is worth an A, unless it doesn't resolve your issue. If it requires you to do a little more research, or figure out one more piece of code, then it's worth a B. If you think it's not worth a B, the custom is to offer the Experts an opportunity to earn a better grade.

Giving a higher grade has no impact on your Available Points.
0
Vee_ModCommented:
No Response to Expert and/or Moderator.
Force changed.
 
Vee_Mod
Experts Exchange Moderator
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.