如何在存储过程之间共享数据 [英] How to Share Data Between Stored Procedures

查看:46
本文介绍了如何在存储过程之间共享数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有许多与在 MS SqlServer 中共享一个存储过程的数据结果相关的问题.

There were a number of questions related to sharing data results of one stored procedure in another in MS SqlServer.

根据 SQL Server 的版本,人们会建议使用临时表、xml (SQLServer 2005) 或表变量 (SQL Server 2008).

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

Erland Sommarskog 写了一篇很棒的文章,提供了全面的答案并列出了不同版本中可用的所有选项SQL:

There is a great article written by Erland Sommarskog that provides comprehensive answer and list all options available in different versions of SQL:

我认为值得分享.

我在阅读答案时看到了那篇文章deevus 建议使用 INSERT-EXEC 声明,这是我的想法以前不太熟悉

I came across that article when reading an answer by deevus suggesting the use of INSERT-EXEC Statement, something that I was not really familiar with before

推荐答案

Erland Sommarskog 提供了全面的答案并列出了不同版本的 SQL 中可用的所有选项:

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

本文解决了两个相关的问题:

This article tackles two related questions:

  • 如何使用一个结果集另一个存储过程,也表示为我如何使用结果从存储过程中设置SELECT 语句?
  • 我怎样才能通过表作为参数来自一个存储程序到另一个?

在本文中我将讨论多种方法,并指出他们的优势和缺点.一些方法仅当您想重用结果集,而其他人则适用于这两种情况.在你想要的情况下要重用结果集,大多数方法要求您重写存储的以一种或另一种方式进行程序,但有一些方法没有.

In this article I will discuss a number of methods, and also point out their advantages and drawbacks. Some of the methods apply only when you want to reuse a result set, whereas others apply in both situations. In the case you want to reuse a result set, most methods require you to rewrite the stored procedure in one way or another, but there are some methods that do not.

这篇关于如何在存储过程之间共享数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆