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)
宠辱不惊,看庭前花开花落;去留无意,望天上云卷云舒