内容 |
1、错误的删除操作: --错误的临时表删除操作,因为所在数据库不同 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 2、正确的删除方式: --正确的临时表删除操作 if object_id('tempdb#temptable') is not null begin drop table #temptable end |