Combining results of multiple stored procedures and send email from SQL Server

I have a series of four stored procedures which pull information from a production database into a reporting database.  Each of these SPs returns a two field (MergeAction, RecCount) recordset with 1, 2, or 3 records indicating the number of records added, updated, or deleted.  I have also created a master SP which I use to pass in the date parameters and call each of the other SPs.  

I now want to figure out how to get those recordsets returned by the individual SP into a string which I can pass in the body of an email sent by the SQL Server.
LVL 52
Dale FyeOwner, Developing Solutions LLCAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Deepak ChauhanSQL Server DBACommented:
You can create a temp table and insert the output of SPs in this table
now you have only one table from where you can select and pass result to email body.

afer the execution of sp_senddbmail you can drop this table.

1.Create table #temp

2.insert into #temp
    exec ('exec sp')

3. select column from #temp

4.  sp_senddbmail @parameters1,.......................

drop table #temp

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dale FyeOwner, Developing Solutions LLCAuthor Commented:
Thanks for your help.  I have the temp table created but need to reformat my Exec statement:

INSERT INTO #Mergetemp Exec('exec df_P2_Merge_01_ProCount_Gas_with_P2_Staging @FromDate')

to get the value that is in the variable @FromDate into the mix.  this is a pure date value with no time component.
Dale FyeOwner, Developing Solutions LLCAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for Dale Fye (Access MVP)'s comment #a40886993

for the following reason:

Process defined in the response worked, but I had to figure out how to handle passing the variable to the stored procedure.  ended up having to ask another question because expert failed to return to this question.  Final solution was:

Exec df_P2_Merge_01_ProCount_Gas_with_P2_Staging @FromDate
Dale FyeOwner, Developing Solutions LLCAuthor Commented:
wrong "solution"
Dale FyeOwner, Developing Solutions LLCAuthor Commented:
Concept of original post worked, but expert failed to return to question to address problem with formatting of the string inside the Exec( ) command.  Final solution to that part of the problem was:

INSERT INTO #MergeTemp EXEC df_myStoredProcedure @FromDate

instead of:

INSERT INTO #MergeTemp EXEC('Exec df_myStoredProcedure @FromDate')
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.