Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Returning rows with a stored procedure

Posted on 2012-03-22
3
Medium Priority
?
187 Views
Last Modified: 2012-03-29
Hi

I hope somebody can help me with the following.

I need to retrieve some records using a SELECT but also using a stored procedure.

Suppose the table (myTable) I have has the following format:

ID      NAME     DOB     SCORE

I have a stored procedure myStoredProcedure(NAME, X, Y, Z)

where NAME and SCORE are values passed in and X, Y and Z are returned values.

This is the pseudo code I'm trying to do

SELECT * FROM myTable WHERE myTable.SCORE = X "using" myStoredProcedure(myTable.NAME, X, Y, Z)

where X is an output parameter from the stored procedure using values from myTable.

Can anybody help?

Thanks in advance

John
0
Comment
Question by:IssacJones
[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
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
Barry Cunney earned 1200 total points
ID: 37752281
Create a user defined scalar function to do the same work myStoredProcedure and return the required value

CREATE FUNCTION ......

Then
SELECT * FROM myTable WHERE myTable.SCORE = dbo.udfYourFunction(NAME, X, Y, Z)
0
 
LVL 17

Expert Comment

by:Barry Cunney
ID: 37752284
The function will have just return a single value - Why are you returning 3 different values - What is the business logic?
May have to look at using a table valued function and cross apply
0
 

Author Comment

by:IssacJones
ID: 37752639
the 3 different values are used in other cases. I'll try your first idea.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

610 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