Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute a stored procedure from within a query 2

Status
Not open for further replies.

dddenney

Programmer
Nov 29, 2000
41
US
Is it possible to execute a store procedure from with in a query? Example of what I would like to do:

select emp_id, last_name, first_name,
(exec sp_Get_Overall_Incentive_Score @emp_id = em.emp_id) as score
from employee_master as em
where term = 0


Thanks in advance for the help,

Dan
 
From the looks of things what you really want to do is create a user defined function. You can create a UDF like this:

Code:
CREATE function dbo.getOverallScore (@emp_id int) returns int
as begin 

declare @Score int

select @Score = Avg(SingleScore) 
from MyScoreData (nolock)

return @Score

end
 
Thank you!

I'm not sure why I didn't think of that in the first place.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top