473,394 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

Jul 23 '05 #1
4 1366
Instead of using the complicated stored procedure, why don't you use a
user defined function?

Jul 23 '05 #2
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" <ch********@gmail.com> wrote in message
news:11********************@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

Jul 23 '05 #3
Sanjeev's right on the money... user defined function will handle this
nicely.

TLetsek
"Chris Auer" <ch********@gmail.com> wrote in message
news:11********************@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

Jul 23 '05 #4
[posted and mailed]

Chris Auer (ch********@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, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: sedefo | last post by:
I ran into this Microsoft Patterns & Practices Enterprise Library while i was researching how i can write a database independent data access layer. In my company we already use Data Access...
5
by: pmud | last post by:
Hi, I need to display columns in a data grid based on 7 different queries. Now I have 32 questions: 1. Is it possble to have 1 single data adapter with 7 queries & 1 data set or do I need to...
6
by: Wojciech Wendrychowicz | last post by:
Hello to All, I'm trying to retrieve records from AS/400 in an VBA application. So, I've made an RPG program, then a stored procedure wchich calls that RPG program, and finally some VBA code to...
4
by: Mike Dinnis | last post by:
Hi, I've been working through a number of turorials to try to learn more about retrieving data from a SQL database. I think i've mastered techniques where i create a sql string in the page and...
6
by: Uday | last post by:
Hi everyone, I have a ASP page that triggers a db-side stored procedure. At the end of the procedure, it spits out a log file, that this ASP page reads and displays for the users. But the...
0
by: aarnan | last post by:
I have two SqlDataSources that use two different stored procedures that take parameters to populate two controls, one dependant on an element of the other. The first data source,...
2
by: sridhar21 | last post by:
hi to all i am sridhar i need a simple example for all type of function in stored procedure thanxs
2
by: jed | last post by:
I have created a stored procedure in SQLExpress management.I need to retrieve a numeric value that the stored procedure creates and use it in a C# application.Please help thanks. USE GO /******...
2
by: Andrew Cooper | last post by:
Greetings, I've got a website that has several pages with DataGrid controls on them. The controls are bound to Object Datasources. On one of the pages I keep getting a "Timeout expired. The...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.