Sql Server 日志自动清理

SQL SERVER DB 版本不同,會有差異

 

 

SQL SERVER 2005

 

USE [master]

BACKUP LOG APP WITH no_log


USE APP

DBCC SHRINKFILE ('APP_log',100)

 

 

SQL SERVER  2008

USE [master]
GO
ALTER DATABASE EMS SET RECOVERY SIMPLE WITH NO_WAIT
GO
ALTER DATABASE EMS SET RECOVERY SIMPLE --简单模式
GO
---------select * from sys.database_files
USE EMS
GO
DBCC SHRINKFILE (N'EMS_log' , 100, TRUNCATEONLY)
GO
 
USE [master]
GO
ALTER DATABASE EMS SET RECOVERY FULL WITH NO_WAIT
GO
ALTER DATABASE EMS SET RECOVERY FULL --还原为完全模式
GO

 

posted @ 2017-04-14 17:17  枯夜留心  阅读(2156)  评论(0编辑  收藏  举报