【发布时间】:2014-01-20 19:15:40
【问题描述】:
我不明白为什么下面的代码会返回错误
消息 2714,第 16 级,状态 1,第 16 行
数据库中已经有一个名为“#temptable”的对象。
如果第 1-5 行分别执行,然后是第 6-8 行,则可以正常工作。我认为我缺少有关 SQL Server 如何处理查询的基本知识。请求一位大师阐明这个问题。
select top 10 col1, col2
into #temptable
from tbl
if object_id('tempdb..#temptable') is not null
drop table #temptable
select top 10 col1, col2
into #temptable
from tbl
【问题讨论】:
标签: sql-server-2012 temp-tables