• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 299
  • Last Modified:

I need assistance with a SQL Server Query

Hi Experts,
I want to create a StoredProc That takes the results of a StoredProc and then I append two columns from a table.  For example:

The original StoredProc returns a students First Name and Last Name, but I also want to display the students teacher's name which

lives in table tblTeacher.  Both the Stored Proc and tblTeacher are linked by the StudentID column.  

Can this be done?  If so, how?

Thanks in advance,
mrotor
0
mainrotor
Asked:
mainrotor
  • 2
2 Solutions
 
UnifiedISCommented:
You can use and INSERT-EXECUTE to add the values from the first proc into a temp table

CReATE TABLE #DEMO  (add your colums)

INSERT INTO #DEMO
EXECUTE proc

SELECT *
FROM #DEMO DEMO
JOIN OtherTable OTHER


DROP TABLE #DEMO

0
 
JestersGrindCommented:
In the new procedure, I would insert the results of the stored procedure that returns the student name into a temp table or table variable.  Then you could join it to the students table based on the first and last name and then join to tblTeacher.  

That being said, why do you want to call the other stored procedure?  It seems like you could do this in a single query without jumping through all of these hoops.  

Greg


0
 
QlemoC++ DeveloperCommented:
I've requested that this question be deleted for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
 
UnifiedISCommented:
2 experts spent time and effort to suggest solutions.  Why don't we get any credit?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now