码迷,mamicode.com
首页 > 数据库 > 详细

删除数据库中所有表

时间:2017-05-15 11:58:19      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:rom   pre   exe   order by   ext   sys   declare   数据库名   删除   

use 数据库名(是要删除表的所在的那个数据库的名称)
GO
declare @sql varchar(8000)
while (select count(*) from sysobjects where type=‘U‘)>0
begin
SELECT @sql=‘drop table ‘ + name
FROM sysobjects
WHERE (type = ‘U‘)
ORDER BY ‘drop table ‘ + name
exec(@sql)
end

删除数据库中所有表

标签:rom   pre   exe   order by   ext   sys   declare   数据库名   删除   

原文地址:http://www.cnblogs.com/shenguanyu/p/6855569.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!