Monday, March 29, 2010

Shrinking File Log – SQL Server with SQL Script

When you monitoring your physical database (SQL Server) you will find file .LDF on big size . It because that file contain your transaction log on your daily operation on database.


And sometime if your harddisk capacity is become out of space, and sometime it make your operational transaction become fail to execute. So you need to execute some script to handle it.

-- 1.to know database information
sp_helpdb YourDBName
-- after that you will find your log file
-- 2.to do shrinkfile action
DBCC SHRINKFILE(YourDBName_log)



Sample best practice on our environment :


image 
PS : when i do this script, i use SQL Server 2008





image





Have a nice try, hope it will help you also.






No comments: