65.9K
CodeProject is changing. Read more.
Home

How to Shrink SQL Server database files?

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Jan 4, 2011

CPOL
viewsIcon

12981

How to Shrink SQL Server database files?

You can shrink the database file by using the following method.

Code

DECLARE @strDatabaseName nvarchar(255)
SET @strDatabaseName = "YourDatabaseName"
DBCC SHRINKDATABASE (@strDatabaseName, 0)--Parameters are Database Name & Target %
Working in both SQL 2005 & 2008.

For Your Information

How to shrink the tempdb database in SQL Server[^]

Acknowledgments

BTW, after this comment[^], I have created this Tip/Trick. Thanks to him.