在 Select 中使用存储过程 (T

编程入门 行业动态 更新时间:2024-10-27 16:34:08
本文介绍了在 Select 中使用存储过程 (T-SQL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要在 select 语句中访问存储过程的结果,即:

I need to access the result of a stored procedure within a select statement, i.e.:

SELECT * FROM [dbo].[sp_sample]

在 SQL_Server 2005 中.

in SQL_Server 2005.

推荐答案

@Barry 是对的您需要先创建一个临时表并插入其中,然后在您的选择中加入该表.

@Barry is right you need to create a temp table and insert into it first, then join that table in your select.

但是,存储过程之间共享数据的方法有很多种,请参阅这篇优秀文章:How to ShareErland Sommarskog 的存储过程之间的数据

However, there are numerous ways for sharing data between stored procedures, see this excellent article: How to Share Data Between Stored Procedures by Erland Sommarskog

一种可能对您有用的方法是共享"临时表.#temp 表是在 Parent 过程中创建的,可供 Child 使用:www.sommarskog.se/share_data.html#temptables

One method that may work for you is to "share" a temp table. The #temp table is created in the Parent procedure and can be used by the Child: www.sommarskog.se/share_data.html#temptables

更多推荐

在 Select 中使用存储过程 (T

本文发布于:2023-10-23 08:18:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1520292.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:存储过程   Select

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!