Script to shrink a database non used space

Leave a comment (2) Go to comments

HOW To SHRINK a Database?

SQL Script to shrink a non used space from a database

-- ***********************************************************************************/
-- Description  :    SQL Script to shrink a non used space from a database
-- Compatibility  :     7.0+
-- This Script should be executed in master
-- ***********************************************************************************/
DBCC shrinkdatabase ( <database name>, <target_percent>)
go

Where

  • database_name Is the name of the database to be shrunk. If 0 is specified, the current database is used.
  • target_percent, is the percentage of free space that you want left in the database file after the database has been shrunk.

OUTPUT


Script to shrink a database non used space sql server shrink database sql server HOW To SHRINK a Database sql script to shrink database HOW To SHRINK a Database DBCC shrinkdatabase

In above example, you see the result only for those database files, which are being shrunk, or in other words SQL Server does not display rows for those files which are not shrunk.

EOF - Script to shrink a database non used space, SQL Server 2012 , 2008 R2 , 2008 , 2005 , 2000
Leave a comment

2 Comments.

  1. AFAIK, SHRINKDATABASE option does not apply to “SQL Azure”, does it? Please, remove that tag.

Leave a Reply

Your email address will not be published. Required fields are marked *


*


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.