while exists(select * from sysobjects where objectproperty(id,'isusertable')=1) exec sp_msforeachtable 'drop table ?'
老大,为什么要用这个select * from sysobjects where objectproperty(id,'isusertable')=1 用这个行么?select * from sysobjects where xtype ='u' "sp_msforeachtable" 是做什么用的?
use tmp go declare @n int,@name varchar(20) select * from sysobjects where type='u' set @n=@@rowcount while @n>0 begin select @name=[name] from sysobjects where type='u' exec('drop table '+@name+'') set @n=@n-1 end go
declare @n int,@name varchar(20) select * from sysobjects where type='u' set @n=@@rowcount while @n>0 begin select @name=[name] from sysobjects where type='u' exec('drop table '+@name+'') set @n=@n-1 end go
用没有公布的存储过程:EXEC SP_MSFOREACHTABLE @command1=" drop table ?" 在这里 ? 代表所有的表
exec sp_msforeachtable 'drop table ?'
用这个行么?select * from sysobjects where xtype ='u'
"sp_msforeachtable" 是做什么用的?
go
declare @n int,@name varchar(20)
select * from sysobjects where type='u'
set @n=@@rowcount
while @n>0
begin
select @name=[name] from sysobjects where type='u'
exec('drop table '+@name+'')
set @n=@n-1
end
go
你的方法报错
服务器: 消息 3701,级别 11,状态 5,行 1
无法 除去 表 'MSreplication_option',因为它在系统目录中不存在。老大方法有用,就是太~~~慢了
select * from sysobjects where type='u'
set @n=@@rowcount
while @n>0
begin
select @name=[name] from sysobjects where type='u'
exec('drop table '+@name+'')
set @n=@n-1
end
go
在这里 ? 代表所有的表