SQL Server Tip: Shrink Database

SQL Server Tip: Shrink Database

This tip works on SQL Server 2000 and SQL Server 2005. To shrink the db, use the logical name. You have to put it into simple recovery mode to get the disk space back. The command I have been running is:

Alter Database MYDBName Set Recovery SIMPLE

DBCC Shrinkfile (MYDBName_Log)

Alter Database MYDBName Set Recovery FULL

I should note that this is for emergency purposes only. It will impact performance by increasing fragmentation within the file and causing a write penalty later when the logs grow.

Posted by