473,883 Members | 1,684 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Return Stored Procudure Values

I have a quick question for you about SQL stored procedures. If I'm
in a stored procedure and want to call another stored procedure and
return values from the second stored procedure what is the procedure?

I know you do the following to run the second stored procedure and pass
in any parameters:
EXEC GetAuthorBooks @AuthorID

So if I wanted the GetAuthorBooks to return all the books for an author
and then populate a temp table in the original stored procedure, how do
I return those records, and populate the temp table?

What do I have to add to this line: EXEC GetAuthorBooks @AuthorID?

Nov 5 '05 #1
4 2075
Ecohouse (vi*******@netz ero.com) writes:
I have a quick question for you about SQL stored procedures. If I'm
in a stored procedure and want to call another stored procedure and
return values from the second stored procedure what is the procedure?

I know you do the following to run the second stored procedure and pass
in any parameters:
EXEC GetAuthorBooks @AuthorID

So if I wanted the GetAuthorBooks to return all the books for an author
and then populate a temp table in the original stored procedure, how do
I return those records, and populate the temp table?

What do I have to add to this line: EXEC GetAuthorBooks @AuthorID?


There are a couple of methods, and I have an article on the topic on
my web site: http://www.sommarskog.se/share_data.html.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Nov 5 '05 #2
Thanks for the info. But I'm still a little confused. How do I create
and return a recordset in the stored procedure?

Nov 6 '05 #3
Ecohouse (vi*******@netz ero.com) writes:
Thanks for the info. But I'm still a little confused. How do I create
and return a recordset in the stored procedure?


I'm not really sure in which context you are asking this question, but to
return a result set from a stored procedure, you simply issue a SELECT
statement.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Nov 6 '05 #4
Thanks for the help. I was able to figure it out. I didn't realize
that once a temp table is created it's global and can be accessed from
another sp and stays active until the original sp finishes running.

Nov 8 '05 #5

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

Similar topics

6
1884
by: ndn_24_7 | last post by:
Hello all, I have a stored procedure that prompts the user for beginning date and ending date to run a monthly report. The prompt says Enter_Beginning_Date and Enter_Ending_Date. I want the prompt to say Enter Beginning Date (Example:1-1-2003) or something like that. Is there a way to do this? CREATE PROCEDURE dbo.MonthlyReport(@Enter_Beginning_Date datetime, @Enter_Ending_Date datetime) AS SELECT incident, @Enter_Beginning_Date AS...
4
4049
by: testemail | last post by:
Hello, does anyone know how to determine (within the stored procedure) whether a parameter has been passed explicitly to a stored procedure as opposed to a parameter that has taken on the default value. Many thanks Phil
1
1544
by: Evgeny Gopengauz | last post by:
Hi! I need to write a t-sql-script like this: (case-1) IF {stored procedure SP is not exists} BEGIN CREATE PROCEDURE SP AS BEGIN //dummy body END
3
2487
by: Niyazi | last post by:
Hi, Me again. I want to create a SQL Server StoreProcedure and I want to access it with ADO.NET. I am using VB.NET. Creating StoreProcedure it was easy but my question is this. I have table with 4 Column and 6 rows. In the Column 3 for all rows I have to insert data. The data considt of the decimal value of Croiss Exchange and 6 my variable as:
8
14015
by: Ravindranath Gummadidala | last post by:
Hi All: I am trying to understand the C function call mechanism. Please bear with me as I state what I know: "every invocation of a function causes a frame for that function to be pushed on stack. this contains the arguments this function was called with, address to return to after return from this function (the location in the previous stack frame), location of previous frame on stack (base or start of this frame) and local variables...
1
1701
by: Machelle Chandler | last post by:
All, I'm trying to populate a datagrid with a data adapter that uses a stored procedure with a parameter. I get the below error when I run my code (as seen below). Any hints? If I delete the .value = "Business Acumen" at the end of the add parameters statement & put the below code on a different row, the error goes away, but I get back an empty dataset.
5
1501
by: Guoqi Zheng | last post by:
Dear sir, I am about to finish a new asp.net application, I used a lot of ms sql stored procedure. Those stored procudure I think is the most important part of the application. Now I am about to distribute this application to clients. I definitely don't like them to look at my stored procedure. Is there a way I can protect the source code of my stored procedure? What
3
1151
by: sonyasam | last post by:
hi everyone: Do anyone know how to create stored procudure of sql server in vb.net IDE? I tried in the Server Eeporer windows, after i creating a data connection, i able to view the tables,views and stored procedures ,but when i right-click "stored procedures", I can not get the "New Stored Procedure" sub menuitem, what is the reason? and i can't edit the exist stored procedure in
0
942
by: janice2k | last post by:
Dear All, I am very new here as well as in the world of .NET. I wonder if it is possible for C# to collect a single value frm stored procudure (which extract data in raw xml). If yes, how can I do so? Appreciate if anyone could assist me. Look forward to some replies soon. Have a pleasant day. Cheers
0
9942
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9792
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10416
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9574
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7129
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5797
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4220
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3233
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.