Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Including output of 1 in another

Author  Topic 

jp2code
Posting Yak Master

175 Posts

Posted - 2008-09-19 : 17:52:33
How can I have a stored procedure run from within another?

Example:
declare @body varchar(4000)
exec @body=sp_GetRecord 'cp19014147808'
select @body


What I want "select @body" to do is create a text dump of the results from the Stored Procedure "sp_GetRecord".

Why?

We are trying to make a mailer that can send information about certain records.

If a record comes in and it does not fit parameters, it is flagged and has to be manually searched on later. If we could somehow take the output from the Stored Procedure and dump that to text, then we could have the date emailed to the right department immediately.

Thanks for any tips and help!


Avoid Sears Home Improvement

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-20 : 01:36:23
what does procedure sp_GetRecord return? if its returning resultset (row of values) how can you store in a variable. In that its better to create a temporary table having same structure as resultset and dump results to it using

INSERT INTO #Temp
EXEC sp_GetRecord 'cp19014147808'


alternatively if it returns a single value make an output parameter in your sp and you it to return the value.
DECLARE @Returnvalue <datatype>
EXEC sp_GetRecord 'cp19014147808',@Returnvalue OUT
Go to Top of Page
   

- Advertisement -