Release unused space using Shrink

Database's size can be optimized using Shrink command. It helps to release unused space. There're 2 ways to do it: via GUI or via T-SQL.

Database’s size can be optimized using Shrink command. It helps to release unused space. There’re 2 ways to do it: via GUI or via T-SQL.

By GUI

  • Connect to SSMS
  • Select target database
  • Right click > Tasks > Shrink > Files (or Database)

By T-SQL

USE [your_database]
GO
DBCC SHRINKDATABASE(N'your_database')
GO

Sometimes SSMS estimates that there’s only few avaible free space (less than 1%) and the shrink is not interesting. However, it might be a doubtful estimation. I’ve gained more than 500 Mb instead of 1 Mb. So just take a try.