if exists (select * from dbo.sysobjects where id = object_id(N'[mytbl]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [mytbl]
GOcreate table [mytbl] (
....
)GO
drop table [mytbl]
GOcreate table [mytbl] (
....
)GO
create table mytbl(....)
select name from dbo.sysobjects where OBJECTPROPERTY(id, N'IsUserTable') = 1
存在
else
不存在
cat
tab
user_tables
1.
if object_id('t_1') is not null
drop table t_1
2.
if exists(select * from dbo.sysobjects where name='t_1' and xtype='U')
drop table t_1