-- 这里的DNName是你要收缩的数据库名,自己注意修改下面的数据库名。
SQL 2005 :
Backup Log DNName with no_log
go
dump transaction DNName with no_log
go
USE DNName
DBCC SHRINKFILE (2)
Go
SQL 2008:
USE [master]
GO
ALTER DATABASE DNName SET RECOVERY SIMPLE WITH NO_WAIT
GO
ALTER DATABASE DNName SET RECOVERY SIMPLE --简单模式
GO
USE DNName
GO
DBCC SHRINKFILE (N'DNName_Log' , 11, TRUNCATEONLY)
GO
USE DNName
GO
SELECT file_id, name FROM sys.database_files;
GO
USE [master]
GO
ALTER DATABASE DNName SET RECOVERY FULL WITH NO_WAIT
GO
ALTER DATABASE DNName SET RECOVERY FULL --还原为完全模式
GO