-----------------------sqlServer2005-----------------------
BACKUP LOG dbname WITH NO_LOG
DBCC SHRINKDATABASE(dbname,10)
-----------------------sqlServer2008-----------------------
--在SQL2008中清除日志就必须在简单模式下进行,等清除动作完毕再调回到完全模式。
USE [master]
GO
ALTER DATABASE dbname SET RECOVERY SIMPLE WITH NO_WAIT
GO
ALTER DATABASE dbname SET RECOVERY SIMPLE --简单模式
GO
USE Test
GO
DBCC SHRINKFILE (N'dbname_Log' , 11, TRUNCATEONLY)
GO
USE [master]
GO
ALTER DATABASE dbname SET RECOVERY FULL WITH NO_WAIT
GO
ALTER DATABASE dbname SET RECOVERY FULL --还原为完全模式
GO
--查看数据库文件名与大小
select name, convert(float,size) * (8192.0/1024.0)/1024. from dbname.dbo.sysfiles
待整理