Home  >  Article  >  Database  >  一段压缩MS SQLServer日志的语句

一段压缩MS SQLServer日志的语句

WBOY
WBOYOriginal
2016-06-07 18:01:19897browse

一段压缩MS SQL Server日志的语句,需要的朋友可以参考下。

代码如下:
--====================================================================
-- 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)
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn