Shrink MS SQL database

Written by Denis Stadler on . Posted in SQL Scripts, SQL Server

Many times when I was developing SharePoint or CRM solutions on virtual machines (yes with small virtual hard disks) it happened to me at some point to receive a lot of unexpected errors.
This happened because of full disk. The quick and dirty fixes for development are truncation of the database log file and shrink the database.
To do this operation you should open the Microsoft SQL Server Management Studio. Click on the New Query button.

Use the following code:

-- replace UserDatabase with you own database name
use UserDatabase
backup log UserDatabase TO DISK='NUL'
dbcc shrinkfile (UserDatabase_log, 1)
GO

Tags: , ,

Trackback from your site.

Denis Stadler

I'm a technology enthusiast, with more than 10 years of experience in SharePoint and Dynamics CRM projects. To find more details about, please visit the about me page.

Leave a comment

*