Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

make a stored procedure reads from another stored procedure?

Posted on 1998-07-13
6
Medium Priority
?
247 Views
Last Modified: 2010-03-19
how can I make a stored procedure read from another stored procedure( select     from [name of stored procedure]). Every time I try to do that I get an error "invalid object name (name of the stored procedure I'm trying to read from). for more information about the question history you can check the question under the title "copy SQL query from Access to SQL"
0
Comment
Question by:khal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Accepted Solution

by:
clarkd earned 80 total points
ID: 1091734
Are the stored procedures (SP) in the same database.  If so then you simply add the line:  exec       <sp_name>
If not then you need to give the full reference to the SP.
If this doesn't help, cut and paste your sp into a comment box.

0
 

Author Comment

by:khal
ID: 1091735
its not working, I added exec <stored proc name> to the calling stored procedure, but still not working. Whats the comment box you talked about, could explain more please?
0
 

Expert Comment

by:zimmy
ID: 1091736
Your question is unclear.

Do you want one stored procedure to read the CODE from another stored procedure? (Why????)

Or do you want one stored procedure to read the data results of another stored procedure?
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

Author Comment

by:khal
ID: 1091737
exactly one stored proc(First) to read the results of another stored proc(second). The results are in a form of a table (i.e. the second stored proc has a select statement that produces a lot of data records and I want the First SP to read these records and do some stuff on them)
0
 

Expert Comment

by:zimmy
ID: 1091738
Have FIRST create a temporary table (name must start with a #) Call SECOND, as clarkd suggests, but have it insert its records into the temp table.
0
 
LVL 4

Expert Comment

by:mitek
ID: 1091739
Something like that. I just answered a similar question.

DECLARE @01 varchar(255)

CREATE TABLE #temp(sid int,fname varchar(10))

INSERT INTO #temp EXEC stored_proc @param1,@param2

SELECT * FROM #temp

DROP TABLE #temp

and the first statement in stored_proc must be something like SELECT filed1,field2, to match the structure of temp table



0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question