SQL server 清空数据库所有表

2023-03-12,,

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

SQL server 清空数据库所有表的相关教程结束。

《SQL server 清空数据库所有表.doc》

下载本文的Word格式文档,以方便收藏与打印。