最近在转移数据,sqlserver的日志文件ldf,占用空间特别大,为了还原库,节省空间,所以压缩日志文件迫在眉睫.在网上找了一段代码: USE [master] GO ALTER DATABASE AFMS SET RECOVERY SIMPLE WITH NO_WAIT GO ALTER DATABASE AFMS SET RECOVERY SIMPLE GO USE AFMS GO DBCC SHRINKFILE (N, TRUNCATEONLY) GO USE [master] GO A