Click here to Skip to main content
15,884,298 members
Articles / Database Development
Tip/Trick

How to Shrink SQL Server database files?

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
5 Jan 2011CPOL 12.8K   1  
How to Shrink SQL Server database files?
You can shrink the database file by using the following method.

Code


SQL
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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --