/*** By Steve, 2008/03/12, Label Cloud Styles ***/ /*** -----------------------------------------***/

2008年3月22日 星期六

[Note] Truncating MS SQL Transaction Log

Note:
MS SQL Server 的交易紀錄滿了怎麼辦?Truncating MS SQL Transaction Log

Database Name: [DBName]
Data File Name: [DBName_Data]
Log File Name: [DBName_Log]

-- 備份 Log File (Optional)
USE MASTER
GO
BACKUP LOG [DBName] WITH TRUNCATE_ONLY
GO
-- 壓縮 Log File
USE [DBName]
GO
DBCC SHRINKFILE ([DBName_Log], 2)
GO
-- 備份 Data File (Optional)
USE MASTER
GO
BACKUP LOG [DBName] WITH TRUNCATE_ONLY
GO
-- 壓縮 Data File
USE [DBName]
GO
DBCC SHRINKFILE ([DBName_Data], 1)
GO

0 Comments: