天天看點

SQL Server 2008 R2 清空資料庫中ldf日志檔案

/************************************************************

 * sql server 2008 r2 清空資料庫中ldf日志檔案

 * 将whir_internalsystem替換為您要操作的資料庫即可

 ************************************************************/

use [master]

alter database [whir_internalsystem] 

set recovery simple with no_wait

set recovery simple

go

use [whir_internalsystem]

declare @logname varchar(150)

select @logname = name

from   sys.database_files

where  name like'%log'

dbcc shrinkfile(@logname, 11, truncateonly)

alter database [whir_internalsystem]

set recovery full with no_wait

set recovery full

注意事項:

1.建議操作前将資料庫做一次完整備份。

2.經過這樣的處理,資料庫将不能做日志恢複,需注意。