Resources, Tech Help, News & Tutorials

The Word

Shrink Your MS SQL Log File via script

by | Feb 8, 2020 | Code & Bits, Technical

If you don’t keep on top of your database maintenance, sometimes you may come across a large log file.  There is a simple way to fix this issue and get back that missing disk space.  Your first step should be to always take a full SQL backup.  Once this has successfully run simple execute the below script replacing the database name with your desired database and select run.  Once complete you will have freed up that lost disk space.

NOTE: Before Purging the Transaction Log, always take a FULL database backup 

Replace sharepoint_config with Your Database Name

use sharepoint_config
alter database sharepoint_config set recovery simple
dbcc shrinkfile('SharePoint_Config_log',100)
alter database sharepoint_config set recovery FUll