加入收藏 | 设为首页 | 会员中心 | 我要投稿 航空爱好网 (https://www.ikongjun.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

SQL server 2000 如何判断临时表是否存在 .

发布时间:2022-12-16 13:21:08 所属栏目:MsSql教程 来源:
导读:  1.判断一个临时表是否存在

  if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempcitys') and type='U')

  drop table #tempcitys

  注

  1.判断一个临时表是否存在
 
  if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempcitys') and type='U')
 
  drop table #tempcitys
 
  注意tempdb后面是两个. 不是一个的
 
  ---临时表
 
  if exists(select * from tempdb..sysobjects where name like ‘#tmp1%‘)
 
  drop table #tmp1
 
  或
 
  if exists( select * from tempdb..sysobjects where id=OBJECT_ID('tempdb..#tmp') )
 
  drop table #tmp1
 
  --视图
 
  if exists (select * from sysobjects where id = object_id(N‘[dbo].[ESTMP]‘)
 
  and OBJECTPROPERTY(idMssq临时表, N‘IsView‘) = 1)
 
  drop view ESTMP
 
  判断表是否存在
 
  if exists (select * from sysobjects where id = object_id(N'[dbo].[phone]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
 
  drop table [dbo].[phone]
 

(编辑:航空爱好网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!