Tuesday, November 18, 2008

script to shink log

First switch to that database,then run this:

==================================

DECLARE @DB varchar(100)
SET @DB = DB_NAME()
BACKUP LOG @DB WITH TRUNCATE_ONLY
DBCC SHRINKDATABASE (@DB, TRUNCATEONLY )


==================================
It worked very well for me in SQL 2005.

This works too but not very convenient:

alter database <mydb> set recovery simple
go

checkpoint
go

alter database <mydb> set recovery full
go

backup database pubs to disk = 'c:\mydb.bak' with init
go

dbcc shrinkfile (N'mydb_log' , 1)
g

No comments: