Solved

sql store procedure query variable usage

Posted on 2011-03-04
6
315 Views
Last Modified: 2012-05-11
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?
0
Comment
Question by:vbnetcoder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 500 total points
ID: 35040075

declare @Product_ID int
SELECT @Product_ID = Product_ID FROM Products    
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 35040085
[ewangoya] is right, but why would you need to query for a product_id you already have?
0
 

Author Comment

by:vbnetcoder
ID: 35040099
paulmacd:

You are correct... i gave you the wrong query.  The concept is what I needed so thank you.
0
Myth Busting: MongoDB Scalability (it scales!)

I was talking with one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. He mentioned to me that several customers have been telling him that “MongoDB doesn’t scale!” MongoDB’s scalability was in question?

My response was, “Is that a joke?"

 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 35040155
>> 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
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 35040165
What's ur requirement ?
0
 

Author Closing Comment

by:vbnetcoder
ID: 35057141
ty
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question