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?
Microsoft SQL Server 2008SQL

Avatar of undefined
Last Comment
vbnetcoder

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Ephraim Wangoya

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Paul MacDonald

[ewangoya] is right, but why would you need to query for a product_id you already have?
vbnetcoder

ASKER
paulmacd:

You are correct... i gave you the wrong query.  The concept is what I needed so thank you.
Rajkumar Gs

>> 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
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Rajkumar Gs

What's ur requirement ?
vbnetcoder

ASKER
ty