MS SQL 清除交易紀錄檔

MS SQL 清除交易紀錄檔

--- 清除交易紀錄檔

DECLARE @LogicalName nvarchar(128)
DECLARE @DataBaseName nvarchar(128)

SELECT @LogicalName =  f.name, @DataBaseName = d.name
FROM sys.master_files f
INNER JOIN sys.databases d ON d.database_id = f.database_id
where d.name = DB_NAME()

ALTER DATABASE CURRENT SET RECOVERY SIMPLE WITH NO_WAIT
DBCC SHRINKFILE(@LogicalName, 1)
ALTER DATABASE CURRENT SET RECOVERY FULL WITH NO_WAIT
iT邦幫忙 個人帳號:Kw6732