SQL Server 2005和SQL Server 2008下日志清理方法

适用于SQL Server 2005

  
    
1 USE [ hrdb ]
2   GO
3 -- 清空数据库缓存
4 DBCC FREEPROCCACHE
5 DBCC DROPCLEANBUFFERS
6 GO
7 BACKUP LOG [ hrdb ] with NO_LOG
8 GO
9 BACKUP LOG [ hrdb ] with TRUNCATE_ONLY
10 GO
11 DBCC SHRINKDATABASE( [ hrdb ] )
12 GO

适用于SQL Server 2008

  
    
1 USE [ master ]
2 GO
3 ALTER DATABASE [ hrdb ] SET RECOVERY SIMPLE WITH NO_WAIT
4 GO
5 ALTER DATABASE [ hrdb ] SET RECOVERY SIMPLE
6 GO
7 USE [ hrdb ]
8 GO
9 DBCC SHRINKFILE (N ' HRServerdb_log ' , 0 ,TRUNCATEONLY)
10 GO
11 USE [ master ]
12 GO
13 ALTER DATABASE [ hrdb ] SET RECOVERY FULL WITH NO_WAIT
14 GO
15 ALTER DATABASE [ hrdb ] SET RECOVERY FULL
16 GO

你可能感兴趣的:(SQL Server 2008)