Loading

Thursday, August 20, 2009

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

No comments:

Post a Comment