Way 1 if(exists(select name from tempdb..sysobjects where name like'%temptab%' and type='U')) drop table #temptab Way 2 www.2cto.com if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempcitys') and type='U') drop table #tempcitys Way 3 IF OBJECT_ID('tempdb..#') IS NOT NULL DROP TABLE # OBJECT_ID此函数返回数据库对象标识号 判断数据库里有没有存在PerPersonData这样一张表 if exists (select * from sysobjects where objectproperty(object_id('PerPersonData'),'istable') = 1) OBJECTPROPERTY:返回当前数据库中对象的有关信息。1表“真”。同样可以写成OBJECTPROPERTY(id,isUserTable) = 1 www.2cto.com if exists (select * from sysobjects where id = object_id(N'PerPersonData') and OBJECTPROPERTY(id,N'IsUserTable') = 1) drop table 'PerPersonData' 判断试图是否存在 if exists (select * from sysobjects where id = object_id(N‘[dbo].[ESTMP]‘) and OBJECTPROPERTY(id,N‘IsView‘) = 1) drop view ESTMP 转自:http://www.2cto.com/database/201209/157718.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。