导航

1. 检索 dbo.sysobjects表,
select count(*) from dbo.sysobjects
where xtype='U' and Name = '你的表名'
 
2. 根据返回的结果判断表是否存在,确定是清楚表的记录,还是建表
-判断t表是否存在,存在删除
declare @num int
set @num=0
select @num=count(*) from dbo.sysobjects where xtype='U' and Name = 't'
if(@num>0)
begin
    drop table t
    
end
GO
--创建T表
create table t
(
    a int,
    b int
)