可用where條件命令列出所感興趣的對象:
SELECT * FROM sysobjects WHERE xtype = ‘ V ‘
判斷數據庫中是否已經存在某個表,有的話就刪除該表
-- 方法一: if exists ( select * from dbo.sysobjects where id = object_id (N ‘ [dbo].[表名] ‘ ) and OBJECTPROPERTY (id, N ‘ IsUserTable ‘ ) = 1 ) drop table [ dbo ] . [ 表名] -- 方法二: if exists ( select * from sysobjects where id = object_id (N ‘ 表名‘ ) and OBJECTPROPERTY (id, N ‘ IsUserTable ‘ ) = 1 ) drop table [ dbo ] . [ 表名] -- 方法三: if ( Exists ( Select * From SysObjects Where xtype = ‘ U ‘ And Name = ‘ 表名‘ )) drop table [ dbo ] . [ 表名]
註: N‘‘代表Unicode類型.可以支持不同語種的對象名