--截断事务日志 backup log 数据库名 with no_log go--收缩数据库 dbcc shrinkdatabase(数据库名) go
這個問題我也遇到,原因經過分析應該是並發數量過多引起的,這個問題同時也反映出了應用程序製作商設計數據庫已經程序的時候的不足,sql2000我感覺它有個很大的問題就是對數据庫非數據空間不能有效釋放,即便你收縮了數據庫也是一樣的。不知道哪位有好的解決辦法,目前我的無奈之擧就是對排在前10位的表分別select into ##然後TRUNCATE,再insert 回來,然後再收縮就ok,很無奈。
是索引太多了 然后频繁插入 更新 删除 造成索引空间很庞大 你可以看下 set nocount on exec sp_MSForEachTable @precommand=N' create table ##( id int identity, 表名 sysname, 字段数 int, 记录数 int, 保留空间 Nvarchar(10), 使用空间 varchar(10), 索引使用空间 varchar(10), 未用空间 varchar(10))', @command1=N'insert ##(表名,记录数,保留空间,使用空间,索引使用空间,未用空间) exec sp_spaceused ''?'' update ## set 字段数=(select count(*) from syscolumns where id=object_id(''?'')) where id=scope_identity()', @postcommand=N'select * from ## order by 记录数 desc drop table ##' set nocount off ------------------------- 邹老大写的 然后在dbcc reindex 重建下索引 在收缩下数据库 就行了
--截断事务日志
backup log 数据库名 with no_log
go--收缩数据库
dbcc shrinkdatabase(数据库名)
go
set nocount on
exec sp_MSForEachTable
@precommand=N'
create table ##(
id int identity,
表名 sysname,
字段数 int,
记录数 int,
保留空间 Nvarchar(10),
使用空间 varchar(10),
索引使用空间 varchar(10),
未用空间 varchar(10))',
@command1=N'insert ##(表名,记录数,保留空间,使用空间,索引使用空间,未用空间) exec sp_spaceused ''?''
update ## set 字段数=(select count(*) from syscolumns where id=object_id(''?'')) where id=scope_identity()',
@postcommand=N'select * from ## order by 记录数 desc drop table ##'
set nocount off
-------------------------
邹老大写的 然后在dbcc reindex 重建下索引 在收缩下数据库 就行了