删除数据库里的所有表
2014-05-14 15:51
204 查看
DECLARE c1 cursor for
select'alter table ['+ object_name(parent_obj)+'] drop constraint ['+name+']; '
from sysobjects
where xtype ='F'
open c1
declare @c1 varchar(8000)
fetch next from c1 into @c1
while(@@fetch_status=0)
begin
exec(@c1)
fetch next from c1 into @c1
end
close c1
deallocate c1
--删除数据库所有表
declare @tname varchar(8000)
set @tname=''
select @tname=@tname+Name+','from sysobjects where xtype='U'
select @tname='drop table '+ left(@tname,len(@tname)-1)
exec(@tname)
select'alter table ['+ object_name(parent_obj)+'] drop constraint ['+name+']; '
from sysobjects
where xtype ='F'
open c1
declare @c1 varchar(8000)
fetch next from c1 into @c1
while(@@fetch_status=0)
begin
exec(@c1)
fetch next from c1 into @c1
end
close c1
deallocate c1
--删除数据库所有表
declare @tname varchar(8000)
set @tname=''
select @tname=@tname+Name+','from sysobjects where xtype='U'
select @tname='drop table '+ left(@tname,len(@tname)-1)
exec(@tname)
相关文章推荐
- MSSQL删除数据库里某个用户所有表里的数据
- mssql批量删除数据库里所有的表
- MSSQL 删除数据库里某个用户所有表里的数据
- SQL删除数据库里所有表的外键,同时删除所有用户表
- SQL删除数据库里所有表的外键,同时删除所有用户表
- 删除表所有数据并恢复自动标识
- 保存中其他对象不变,删除数据库中所有数据的实现方法
- [转]mssql中得到库里所有的表名,以及表的结构(列名和数据类型)
- [转]mssql中得到库里所有的表名,以及表的结构(列名和数据类型)
- 保存数据库中其他对象不变,删除数据库中所有数据的实现方法
- oracle删除表空间中一用户对应的所有数据
- World Wide Web Publishing 服务尝试删除 IIS 所有的 SSL 配置数据失败的几种方法
- 保存数据库中其他对象不变,删除数据库中所有数据的实现方法
- 删除一个数据库中所有数据的方法
- 一条SQL删除所有用户自定义数据表,存储过程
- 一条SQL删除所有表中数据
- 删除数据库中所有表数据
- 自增列删除所有数据后归零的解决办法
- 删除所有表中数据