[翻译]  Trying to insert a stored procedure into a temporary table, getting 'an object or column name is missing or empty' [duplicate]

[CHINESE]  尝试将存储过程插入临时表,使“对象或列名称丢失或为空”[复制]


Possible Duplicate: How to SELECT * INTO [temp table] FROM [Stored Procedure]

可能重复:如何选择* INTO [临时表] FROM [存储过程]

I am new to T-SQL. I have a stored procedure that selects records. I want to query the records returned by the stored procedure, so I am trying to insert the records into a temporary table. (Stack Overflow posts and other posts say that is how to do it.)

我是T-SQL的新手。我有一个选择记录的存储过程。我想查询存储过程返回的记录,所以我试图将记录插入临时表。 (Stack Overflow帖子和其他帖子说这是怎么做的。)

But when I try, I get the error:

但是当我尝试时,我得到错误:

object or column name is missing or empty'

对象或列名称缺失或为空

When I just run the stored procedure, I get a table that has columns with names.

当我只运行存储过程时,我得到一个包含名称列的表。

select * into #temp1
exec alexander.dbo.get_uberrecords '20120101', '20120201', 'labcorp' //throws error saying columns must have names

but

exec alexander.dbo.get_uberrecords '20120101', '20120201', 'labcorp' // Returns cols with names

What am I missing?

我错过了什么?

1 个解决方案

#1


6  

Try creating the temp table first:

首先尝试创建临时表:

CREATE TABLE #temp1
(
   COL1 INT,
   COL2 VARCHAR(MAX)   
)

INSERT INTO #temp1 
exec alexander.dbo.get_uberrecords '20120101', '20120201', 'labcorp'

In your case of an extremely wide result set, you may want to use OPENROWSET

在极端宽的结果集的情况下,您可能想要使用OPENROWSET

In any case, this SO has many options: Insert results of a stored procedure into a temporary table

在任何情况下,此SO都有许多选项:将存储过程的结果插入临时表中


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2018 ITdaan.com 粤ICP备14056181号