一段緊縮MS SQLServer日記的語句。本站提示廣大學習愛好者:(一段緊縮MS SQLServer日記的語句)文章只能為提供參考,不一定能成為您想要的結果。以下是一段緊縮MS SQLServer日記的語句正文
--====================================================================
-- 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)