很简单的if else 语句!!!
我现在想检测一张表,如果表存在,就删除它,应该怎么写呀 问题点数:5、回复次数:4Top
1 楼xdhou(办公室坐久了,想晒晒太阳)回复于 2005-06-21 13:54:10 得分 2
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ASN_WMS]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[ASN_WMS]
GO
Top
2 楼Frewin(frewin)回复于 2005-06-21 14:19:28 得分 1
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tb]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tb]Top
3 楼filebat(Mark)回复于 2005-06-21 17:57:03 得分 1
--假定表名为表A
if object_id('表A') is not null drop table 表A
go
create table 表A (...)
--另问,这种方法和直接查sysobjects方法,会不会出现查出的效果不一致?Top
4 楼xiaonvjing(飞扬)回复于 2005-06-21 18:47:44 得分 1
if exists(select name from sysobjects where name='table1')
drop table table1
else
create table table1 (id int,name varchar(8))Top




