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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored procedures inside a SELECT statement

Status
Not open for further replies.

againstTheWind

Programmer
Jun 22, 2006
42
US

I am trying to use a stored produced to contain an entire SELECT statement. What code do I need to use to create a view with a couple of the same stored procedures(but with different variables being passed).

Something like
exec proc1 88,99
exec proc1 95, 21
??


Thanks!
 
You can't create a view that calls a stored procedure.

You could create another stored procedure that combines the results of 2 stored procedure calls. Wanna see how?

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
This is probably best shown with an example.

First, create this stored procedure.

Code:
Create Procedure Test1
	@Param1 Integer,
	@Param2 Integer
As
SET NOCOUNT ON
Select @Param1 * @Param2 As Multiplication,
       @Param1 + @Param2 As Addition,       
       @Param1 - @Param2 As Subtraction

Then, create a stored procedure to combine the results, like so...

Code:
Create Procedure Combine
As
SET NOCOUNT ON

Create Table #Output(Multiplication Integer, Addition Integer, Subtraction Integer)

Insert Into #Output
Exec test1 88,99

Insert Into #Output
Exec test1 95,21

Select * From #Output

Then, you can test it with...

[tt][blue] exec combine[/blue][/tt]


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top