SQL Server 插入...执行语句 [英] SQL Server Insert into. . . Execute Statement

查看:42
本文介绍了SQL Server 插入...执行语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个存储过程来返回一个包含大约 60 列的记录.但是,我想在我的项目的另一部分中从它返回的 60 列中的大约 40 列中选择同一个存储过程.如何正确指定需要返回的列?本质上是什么规则,如果有的话

I created a stored procedure to return a record containing about 60 columns. However, I would like to in another part of my project select from the same stored proc about 40 out of the 60 columns it returns. How do I properly specify which columns I need returned? In essence what are the rules, if any for

插入#TempTable(…………)执行存储过程

?

推荐答案

规则非常简单.SP 中的 select 必须具有与 #Temptable 一样多的列,并且这些列如果不是完全相同的类型,则必须兼容或可协调,例如int 进入 VARCHAR.

The rules are pretty simple. The select within the SP has to have as many columns as the #Temptable, and the columns, if not exactly the same type, must be compatible or coorcible, e.g. int going into VARCHAR.

如果必须从 60 列中选择 40 列,则必须通过 2 个临时表传递它,或者使用涉及 OPENQUERY 之类的技巧将 SP 调用视为远程数据集.

If you have to select 40 out of 60 columns, you will have to pass it through 2 temporary tables, or use hacks involving the likes of OPENQUERY to treat the SP call as a remote dataset.

这篇关于SQL Server 插入...执行语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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