【发布时间】:2019-09-18 13:04:04
【问题描述】:
当我删除一个表并重用它时,部分代码需要在两个临时表之间进行交换,但我不能
create table #temp (id int)
create table #swap (id int)
drop table #temp
select * into #temp from #swap
drop table #swap
drop table #temp
我收到此错误
消息 2714,第 16 级,状态 1,第 6 行 数据库中已经有一个名为“#temp”的对象。
【问题讨论】:
-
Why DROP TABLE doesn't seem to take effect before a SELECT INTO? 您需要在第二个 CREATE TABLE 和第一个 DROP TABLE 之后添加
GO -
我不能使用
GO,因为这段代码是while循环的一部分
标签: sql-server-2012 temp-tables