Shrink (truncate) Microsoft SQL transaction log files

Shrink (truncate / purge) MS SQL transaction log files.

Use <dbname>
Go
alter database <dbname> set recovery simple
go
dbcc shrinkfile (<dbname>_log, 100)
go
checkpoint
go
dbcc shrinkfile (<dbname>_log, 100)
alter database <dbname> set recovery full
go

Example:

Use myDatabase
Go
alter database myDatabase set recovery simple
go
dbcc shrinkfile (myDatabase_log, 100)
go
checkpoint
go
dbcc shrinkfile (myDatabase_log, 100)
alter database myDatabase set recovery full
go

Leave a Reply

Your email address will not be published. Required fields are marked *