如果临时表存在,我正尝试删除它,但出现以下错误。我过去曾在表格中使用过这种方法,我不确定为什么在这种情况下它不起作用。
SQL
Create table mytable(col_a int)
insert into mytable
values(1)
IF object_id(#temp, 'U') IS NOT NULL
drop table #temp
select *
into #temp
from dbo.mytable
错误:
Msg 207, Level 16, State 1, Line 8
Invalid column name '#temp'.
最佳答案
对于来自 SQL Server 2016 的 future (你好!)的访问者
DROP TABLE IF EXISTS #temp;
关于sql-server - SQL Server 删除表错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38258392/