Wednesday, February 25, 2009

Database Log file Shrink

Some times i come across this need (shrinking database log file) and always do some research on internet to find the solution, but the problem is in most cases the info is not complete, so i am listing the steps below to be refrence for me and others in future :)

Step1: Taking backup from log file

BACKUP LOG myDBName WITH TRUNCATE_ONLY

Step2: Getting files logical name

EXEC sp_helpfile

it will be the first column on the list

Step3: Shrinking the database

DBCC
SHRINKFILE
(, 2000)
WITH NO_INFOMSGS

Notes:

1- Using the logical name of logfile not physical when shrinking.
2- Taking backup of log file before proceed (second step).

Hope this helps,

Salam.,

No comments: