我同事写的一段压缩MS SQL Server日志的语句
1 --====================================================================
2 -- SQL:数据库压缩语句
3 ----------------------------------------------------------------------
4 -- Description: 压缩数据库
5
6 -- Modify: x.zhong
7 --====================================================================
8 DECLARE @db_name varchar(200)
9
10 --得到当前数据库名称
11 declare getdbname cursor for select db_name()
12 open getdbname
13 fetch getdbname into @db_name
14 while @@fetch_status = 0
15 begin
16 fetch getdbname into @db_name
17 end
18 close getdbname
19 DEALLOCATE getdbname
20
21 --压缩数据库日志
22 DUMP TRANSACTION @db_name WITH NO_LOG
23 BACKUP LOG @db_name WITH NO_LOG
24 DBCC SHRINKDATABASE(@db_name)
2 -- SQL:数据库压缩语句
3 ----------------------------------------------------------------------
4 -- Description: 压缩数据库
5
6 -- Modify: x.zhong
7 --====================================================================
8 DECLARE @db_name varchar(200)
9
10 --得到当前数据库名称
11 declare getdbname cursor for select db_name()
12 open getdbname
13 fetch getdbname into @db_name
14 while @@fetch_status = 0
15 begin
16 fetch getdbname into @db_name
17 end
18 close getdbname
19 DEALLOCATE getdbname
20
21 --压缩数据库日志
22 DUMP TRANSACTION @db_name WITH NO_LOG
23 BACKUP LOG @db_name WITH NO_LOG
24 DBCC SHRINKDATABASE(@db_name)
版权声明: 本文为博主 网无忌 原创文章,欢迎转载,但请务必标注原文链接。
本文链接: https://www.cnblogs.com/netWild/archive/2010/11/30/1892383.html