Wednesday, September 15, 2010

How to clear transaction log in a database (MS SQL 2005, 2008)

The solution is straight forward, but it took some time to find it. Just use the following code:
Dump tran <Database name> with truncate_only

1 comment:

Oleg Shilovsky said...

А я вот так делаю. Обязательно CHECKPOINT перед DBCC SHRINKFILE

тоже работает стабильно хорошо

USE DBNAME;
GO
ALTER DATABASE DBNAME
SET RECOVERY SIMPLE;
GO

CHECKPOINT
DBCC SHRINKFILE (DBLOGNAME, 1024);
GO
ALTER DATABASE DBNAME
SET RECOVERY FULL;