How to share data between stored procedures

A number of questions were asked regarding the sharing of data from one stored procedure to another in MS SqlServer.

Depending on the version of SQL Server, people would suggest using temporary tables, xml (SQLServer 2005), or variable tables (SQL Server 2008).

There is a wonderful article written by Erland Sommarskog that provides an exhaustive answer and a list of all the options available in different versions of SQL:

I thought it was worth sharing.

I came across this article when I read deevus answer , suggesting to use the INSERT-EXEC Statement , something that I did not know about before.

+4
source share
1 answer

There is a wonderful article written by Erland Sommarskog that gives an exhaustive answer and lists all the options available in different versions of SQL:

This article addresses two related issues:

  • How can I use a result set from one stored procedure in another, just as I can use the result from a stored procedure in a SELECT call?
  • How can I pass a table as a parameter from one stored procedure to another?

In this article I will discuss a number of methods, as well as indicate their advantages and disadvantages. Some of the methods apply only when you want to reuse a result set, while others apply in both situations. In case you want to reuse the result set, most methods need to rewrite the stored procedure anyway, but there are some methods that don't.

+9
source

All Articles