473,793 Members | 2,927 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 2073
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
1881
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
4047
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
1542
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
2485
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
14009
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
1698
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
1498
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
1148
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
940
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
9670
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
9518
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
10211
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10159
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
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
9033
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...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
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
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.