请看下面的代码:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE Test
AS
BEGIN
begin
select * into #dbreviews from dbreviews
end
drop table #dbreviews
begin
select * into #dbreviews from dbreviews
end
END
GO
我得到的错误是:
There is already an object named
'#dbreviews'
in the database.
这样的问题:There is already an object named '#columntable' in the database告诉我这应该是可能的。
最佳答案
根据 SQL Server 规范,这是不允许的。请引用documentation .
If more than one temporary table is created inside a single stored procedure or batch, they must have different names.
您正在创建两个具有相同名称 #dbreviews
的临时表。这是不允许的。
关于sql - 存储过程 : There is already an object named '#columntable' in the database,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42132643/