Tuesday 18 December 2007

Honey, I shrank the log file.

How to shrink a SQL Server transaction log file.

It always happens when you least expect it, your application starts to go mental (if you are luckly) sometimes your server just crashes.

What could it be? Your SQL Server transaction log file has eaten up your entire hard disk and you are now stuck.

It’s too big to move and you don’t have any space to do a backup because the log file is using up all the space.

To get your application (your SQL Server) back up and running, run the follow SQL.

dump transaction <DBNAME> with no_log

then

DBCC SHRINKFILE(<LOG FILE LOGICAL FILE NAME>,2)


References:
INF: Shrinking the Transaction Log in SQL Server 2000 with DBCC SHRINKFILE (
http://support.microsoft.com/kb/272318/)

INF: Transaction Log Still Full After DUMP TRAN WITH NO_LOG (
http://support.microsoft.com/kb/184499)

No comments: