create table #temp
(
id int identity(1,1),
customer nvarchar(50)
(
id int identity(1,1),
customer nvarchar(50)
)
selectidentity(int ,1,1) as id,*into #temp1 fromtachecontractid --#temp1没有提前声明
所以比较可靠的做法,还是先判断临时表是否存在,然后再drop table if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempcitys') and type='U') drop table #tempcitys