--错误的临时表删除操作,因为所在
数据库不同
IF EXISTS (SELECT * FROM sysobjects WHERE object_id = OBJECT_ID(N'[dbo].[#tempTable]') AND type in (N'U'))
Begin
DROP TABLE [dbo].[tempTable]
End
--错误的临时表删除操作,因为临时表名已变
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'[#temptable]'))
Begin
drop table #temptable
End