Unix Technical Forum

Getting Data from a storeed procedure in a stored procedure

This is a discussion on Getting Data from a storeed procedure in a stored procedure within the SQL Server forums, part of the Microsoft SQL Server category; --> What I am looking to do is use a complicated stored procedure to get data for me while in ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 08:47 AM
Chris Auer
 
Posts: n/a
Default Getting Data from a storeed procedure in a stored procedure

What I am looking to do is use a complicated stored procedure to get
data for me while in another stored procedure.

Its like a view, but a view you can't pass parameters to.

In essence I would like a sproc that would be like this

Create Procedure NewSproc
AS

Select * from MAIN_SPROC 'a','b',.....
WHERE .........


Or Delcare Table @TEMP
@Temp = MAIN_SPROC 'a','b',.....

Any ideas how I could return rows of data from a sproc into another
sproc and then run a WHERE clause on that data?

Thanks
Chris Auer

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 08:47 AM
Sanjeev
 
Posts: n/a
Default Re: Getting Data from a storeed procedure in a stored procedure

Instead of using the complicated stored procedure, why don't you use a
user defined function?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 08:47 AM
John Bell
 
Posts: n/a
Default Re: Getting Data from a storeed procedure in a stored procedure

Hi

You may be better with a table function, but for a stored procedure you can
create a (temporary) table and use the INSERT...EXEC statement (see Books
online)

e.g.
CREATE TABLE #temporary_table (col1 char(1), col2 char(1) )

INSERT INTO #temporary_table (col1, col2 ) EXEC my_proc

SELECT col1, col2 FROM #temporary_table

John

"Chris Auer" <chris.auer@gmail.com> wrote in message
news:1117740278.709876.4550@o13g2000cwo.googlegrou ps.com...
> What I am looking to do is use a complicated stored procedure to get
> data for me while in another stored procedure.
>
> Its like a view, but a view you can't pass parameters to.
>
> In essence I would like a sproc that would be like this
>
> Create Procedure NewSproc
> AS
>
> Select * from MAIN_SPROC 'a','b',.....
> WHERE .........
>
>
> Or Delcare Table @TEMP
> @Temp = MAIN_SPROC 'a','b',.....
>
> Any ideas how I could return rows of data from a sproc into another
> sproc and then run a WHERE clause on that data?
>
> Thanks
> Chris Auer
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-29-2008, 08:48 AM
TLetsek
 
Posts: n/a
Default Re: Getting Data from a storeed procedure in a stored procedure

Sanjeev's right on the money... user defined function will handle this
nicely.

TLetsek


"Chris Auer" <chris.auer@gmail.com> wrote in message
news:1117740278.709876.4550@o13g2000cwo.googlegrou ps.com...
> What I am looking to do is use a complicated stored procedure to get
> data for me while in another stored procedure.
>
> Its like a view, but a view you can't pass parameters to.
>
> In essence I would like a sproc that would be like this
>
> Create Procedure NewSproc
> AS
>
> Select * from MAIN_SPROC 'a','b',.....
> WHERE .........
>
>
> Or Delcare Table @TEMP
> @Temp = MAIN_SPROC 'a','b',.....
>
> Any ideas how I could return rows of data from a sproc into another
> sproc and then run a WHERE clause on that data?
>
> Thanks
> Chris Auer
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-29-2008, 08:50 AM
Erland Sommarskog
 
Posts: n/a
Default Re: Getting Data from a storeed procedure in a stored procedure

[posted and mailed]

Chris Auer (chris.auer@gmail.com) writes:
> What I am looking to do is use a complicated stored procedure to get
> data for me while in another stored procedure.
>
> Its like a view, but a view you can't pass parameters to.
>
> In essence I would like a sproc that would be like this
>
> Create Procedure NewSproc
> AS
>
> Select * from MAIN_SPROC 'a','b',.....
> WHERE .........
>
>
> Or Delcare Table @TEMP
> @Temp = MAIN_SPROC 'a','b',.....
>
> Any ideas how I could return rows of data from a sproc into another
> sproc and then run a WHERE clause on that data?


There are a couple options, please see an article on my web site:
http://www.sommarskog.se/share_data.html.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:58 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com