gpt4 book ai didi

sql-server - 尝试将存储过程插入临时表,得到 'an object or column name is missing or empty'

转载 作者:行者123 更新时间:2023-12-02 13:18:35 25 4
gpt4 key购买 nike

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

我是 T-SQL 的新手。我有一个stored procedure选择记录。我想查询存储过程返回的记录,因此我尝试将记录插入到临时表中。 (堆栈溢出帖子和其他帖子都说这是如何做到的。)

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

object or column name is missing or empty'

当我刚刚运行存储过程时,我得到一个表,其中包含带有名称的列。

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

但是

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

我错过了什么?

最佳答案

首先尝试创建临时表:

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

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

如果结果集非常宽,您可能需要使用OPENROWSET

无论如何,这个 SO 有很多选择: Insert results of a stored procedure into a temporary table

关于sql-server - 尝试将存储过程插入临时表,得到 'an object or column name is missing or empty',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10145868/

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