SQL server 2000 如何判断临时表是否存在 .
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempcitys') and type='U')
drop table #tempcitys
注意tem
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] (编辑:威海站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |