I have a stored procedure that takes a product_id and returns some data about the product. I would like to make a query or procedure that maps this stored proc over a “select * from products” query. Is there a way to do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It sounds like you need a user-defined function and not a stored proc. A user-defined function can be evaluated as part of a query (e.g. SELECT id, myFunc(id) AS ‘Product Info’ FROM Products).
See CREATE FUNCTION in SQL Server BOL
By the way, stored procs are permitted to be non-deterministic while UDFs are not. If your current stored proc is non-deterministic, you’ll need to do so refactoring/redesiging in order to create UDFs that can be included in your query.