SQL server 清空数据库所有表

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


use [stk_min]
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

上一篇:JS推箱子项目总结——地图创建与铺设简述(二)


下一篇:SQL语句中----删除表数据drop、truncate和delete的用法