use my_database
go
--删除外键约束
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 c2 cursor for
select 'drop table ['+name +']; '
from sysobjects
where xtype = 'u'
open c2
declare @c2 varchar(8000)
fetch next from c2 into @c2
while(@@fetch_status=0)
begin
exec(@c2)
fetch next from c2 into @c2
end
close c2
deallocate c2
相关文章:
- 删除数据库中所有表 2021-10-16
- 清空数据库中的所有用户表(删除数据库中的表) 2022-02-09
- MS-SQL 删除数据库所有的表 2021-07-09
- 一句sql删除数据库中的所有表 2022-12-23
- SQL删除数据库中所有用户数据表外键 - 风灵溪清 2021-12-10
- sql删除数据库中所有表与数据语句 2021-11-07
- Mysql删除数据库中所有表 2021-08-18
- 删除MSSQL数据库中所有表 2022-12-23