Link to home
Start Free TrialLog in
Avatar of vbnetcoder
vbnetcoder

asked on

sql store procedure query variable usage

I have this query:

SELECT Product_ID FROM Products WHERE Product_ID = @Product_ID      

I want to put the value of product_ID into a variable so I can use it later in my stored procedure.

How?
ASKER CERTIFIED SOLUTION
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
[ewangoya] is right, but why would you need to query for a product_id you already have?
Avatar of vbnetcoder
vbnetcoder

ASKER

paulmacd:

You are correct... i gave you the wrong query.  The concept is what I needed so thank you.
>> I want to put the value of product_ID into a variable so I can use it later in my stored procedure.

Make sure you are passing the value for productid to the stored procedure.
@Product_ID  

This will be available all over the stored procedure, no need to modify the query for that purpose.

Your query seems to be have no logic!

SELECT Product_ID FROM Products WHERE Product_ID = @Product_ID

Retrieve productid by passing same product.

Check what you want

If it is something like this, I would say ok

SELECT * FROM Products WHERE Product_ID = @Product_ID
What's ur requirement ?
ty