gpt4 book ai didi

sql - 如何在存储过程之间共享数据

转载 作者:行者123 更新时间:2023-12-02 09:09:01 24 4
gpt4 key购买 nike

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

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

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

我认为值得分享。

我在 reading an answer by deevus 时看到了那篇文章建议使用INSERT-EXEC Statement ,一些我以前不太熟悉的东西

最佳答案

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

This article tackles two related questions:

  • How can I use the result set from one stored procedure in another, also expressed as How can I use the result set from a stored procedure in a SELECT statement?
  • 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, 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.

关于sql - 如何在存储过程之间共享数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/469062/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com