sql server临时表怎么删除?正确删除sql临时表的方法
http://www.yqxbc.com  发布时间:2015-11-03 09:26 来源:一起学编程网 浏览:加载中

--错误的临时表删除操作,因为所在数据库不同

IF EXISTS (SELECT * FROM sysobjects WHERE object_id = OBJECT_ID(N'[dbo].[#tempTable]') AND type in (N'U'))
Begin
DROP TABLE [dbo].[tempTable]
End
--错误的临时表删除操作,因为临时表名已变 by yqxbc.com
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


如果你有好的win10资讯或者win10教程,以及win10相关的问题想要获得win10系统下载的关注与报道。
欢迎加入发送邮件到657025171#qq.com(#替换为@)。期待你的好消息!