一段压缩MS SQLServer日志的语句
(编辑:jimmy 日期: 2024/12/24 浏览:3 次 )
复制代码 代码如下:
--====================================================================
-- SQL:数据库压缩语句
----------------------------------------------------------------------
-- Description: 压缩数据库
-- Modify: x.zhong
--====================================================================
DECLARE @db_name varchar(200)
--得到当前数据库名称
declare getdbname cursor for select db_name()
open getdbname
fetch getdbname into @db_name
while @@fetch_status = 0
begin
fetch getdbname into @db_name
end
close getdbname
DEALLOCATE getdbname
--压缩数据库日志
DUMP TRANSACTION @db_name WITH NO_LOG
BACKUP LOG @db_name WITH NO_LOG
DBCC SHRINKDATABASE(@db_name)
--====================================================================
-- SQL:数据库压缩语句
----------------------------------------------------------------------
-- Description: 压缩数据库
-- Modify: x.zhong
--====================================================================
DECLARE @db_name varchar(200)
--得到当前数据库名称
declare getdbname cursor for select db_name()
open getdbname
fetch getdbname into @db_name
while @@fetch_status = 0
begin
fetch getdbname into @db_name
end
close getdbname
DEALLOCATE getdbname
--压缩数据库日志
DUMP TRANSACTION @db_name WITH NO_LOG
BACKUP LOG @db_name WITH NO_LOG
DBCC SHRINKDATABASE(@db_name)
下一篇:sqlserver中Case的使用方法(上下篇)第1/2页