Monday, April 16, 2012

Reducing the size of Sql Server log files

How do I trim down the size of log files in MSSQL 2008?
A quarter of my precious SSD disk space on my dev laptop was in database log files, the *.ldf files in C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA.
Since I'm not a Sql Server expert, I googled and stackoverflowed and patched together the minimum statement I needed to rid me of these tenacious ldf files.
Do not use these on production machines. Use only on development boxes where you are testing and really don't care about the database. This statement took the log size of my typical database from 15Gig to 30K.
DBCC SHRINKDATABASE ([MyDatabaseName], 10, TRUNCATEONLY)

1 comment:

Anonymous said...

Great Post.It reduced my ldf file size to 1 GB from 79 GB. Thanks a lot