Home > SQL Server Tips > Database Management and Administration > How to disable the Shrink Database task in SQL Server 2000 and 2005
SQL Server Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DATABASE MANAGEMENT AND ADMINISTRATION

How to disable the Shrink Database task in SQL Server 2000 and 2005


Michelle Gutzait, Contributor
10.23.2008
Rating: -4.50- (out of 5)


Expert advice on database administration
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


Routinely shrinking your SQL Server database is not always the best strategy for saving space, and when a DBA realizes that, the next step is to figure out how to kill the automatic task. SQL Server expert Michelle Gutzait discusses three common methods for shrinking the database and how to disable them.


Problem:

My database is being shrunk automatically but I don't know how to disable this. Please advise.

A note from the author:

Shrinking the database or database files on a routine basis is not always recommended. When the database file needs to grow during a transaction, shrinking the database may degrade performance. For more information, refer to my tip Shrinking your SQL Server database to death.

Ways to shrink database automatically:

  1. Auto shrink database option
  2. Shrink database maintenance task/plan
  3. Customized job

How to disable automatic shrink of a database

1) Auto shrink database option

Here's how to manually kill the auto shrink database option in both SQL Server 2000 and SQL Server 2005:

ALTER DATABASE dbname SET AUTO_SHRINK OFF

Another option is to use the GUI (Enterprise Manager/SQL Server Management Studio):

In SQL Server 2000, right click on the database - Properties - Options:

Disable the Auto Shrink option in SQL Server 2000 by leaving it empty
Figure 1: Disable the Auto Shrink option in SQL Server 2000 by leaving it empty. (Click on image for enlarged view.)

In SQL Server 2005, right click on the database - Properties - Options:

Disable the Auto Shrink option in SQL Server 2005 by setting it to False
Figure 2: Disable the Auto Shrink option in SQL Server 2005 by setting it to False. (Click on image for enlarged view.)

2) Shrink database maintenance task/plan

With Enterprise Manager in SQL Server 2000, open the maintenance plan by double clicking on it:

Open the maintenance plan in SQL Server Enterprise Manager
Figure 3: Open the maintenance plan in SQL Server Enterprise Manager. (Click on image for enlarged view.)

Go to the Optimization tab and disable the shrink database option:

Disable the shrink database option from the Optimization tab
Figure 4: Disable the shrink database option from the Optimization tab. (Click on image for enlarged view.)

You also have the following options:

If the shrink database task is the only task in the maintenance plan, you can do any of these:
Delete the maintenance plan.
Disable the job running the maintenance plan.
Remove the schedule of the maintenance plan – this will remove the job. You do that by clicking on Schedule - Change button and then disable the Enable schedule option on the right top.

If the shrink database task is NOT the only task in the maintenance plan, you can do either of these:
Disable the option as described above.
Disable schedule (if there's no need to reorganize the indexes).

In Management Studio in SQL Server 2005, open the maintenance plan by double clicking it:

In Management Studio in SQL Server 2005, double click on the maintenance plan.
Figure 5: In SQL Server 2005 Management Studio, double click on the maintenance plan. (Click on image for enlarged view.)

Find the task responsible for shrinking the database and double click on it:

Find SQL Server Management Studio task responsible for shrinking the database and double click on it
Figure 6: Find SQL Server Management Studio task responsible for shrinking the database and double click on it. (Click on image for enlarged view.)

Now you have a few options:

  1. If the shrink database task is the only task in the maintenance plan, you can do any of these:
    1. Delete the maintenance plan.
    2. Disable the job running the maintenance plan.
    3. Remove the schedule of the maintenance plan – this removes the job.

  2. If the shrink database task is NOT the only task in the maintenance plan, you can do either of these:
    1. Remove the task from the maintenance plan.
    2. Leave it empty (no database selected).

3) Customized job

I've seen cases where the shrink database task is performed automatically by a customized job. You will either find a job with a name ((Content component not found.)) implying its goal is to shrink the database or you'll find the text (for both, SQL Server 2000/2005):

DBCC SHRINKDATABASE

Or

DBCC SHRINKFILE

The first command shrinks the database, the second shrinks a specific file. Here are your options to kill the auto shrink of a customized job in SQL Server:

  1. Remove the step from the job (if it's not the only one).
  2. Convert the part of code that shrinks the database/file to be a comment.
  3. Disable the job (if it's only shrinking the database/file).
  4. Remove the job's schedule (if it's only shrinking the database/file).

ABOUT THE AUTHOR:   
Michelle Gutzait works as a team member of the SQL Server Database Experts at www.pythian.com, a worldwide company providing Remote Administration services for databases, operating systems, SANs and networks. Gutzait has been involved in IT for 20 years as a developer, business analyst and database consultant. For the past 10 years, she has worked exclusively with SQL Server. Her skills include SQL infrastructure and database design, performance tuning, security, high availability, disaster recovery, very large databases, replication, T-SQL coding, DTS/SSIS packages, administrative and infrastructure tools development, reporting services and more. Copyright 2008 TechTarget

MEMBER FEEDBACK TO THIS TIP

Do you have a comment on this tip? Let us know.


Rate this Tip
To rate tips, you must be a member of SearchSQLServer.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
Microsoft SQL Server Performance Monitoring and Tuning
SQL Server Mailbag: CALs, witnesses and unwanted changes
SQL Server Mailbag: Data restoration and DB property management
Working with IntelliSense in SQL Server 2008 Management Studio
SQL Server Mailbag: Stored procedures, triggers and SSRS reports
Troubleshooting Distributed Transaction Coordinator errors in SQL Server
Clearing the Windows page file and its effect on server performance
Optimizing SQL Server indexes –- even when they're not your indexes
Performance implications of transaction log autogrowth in SQL Server
The short course on how SQL Server really works
Determining the source of full transaction logs in SQL Server

Database Management and Administration
Meet compliance requirements with improved database security practices
Hardening the network and OS for SQL Server security
Securing the server and database in SQL Server
How SQL Server 2008 components impact SharePoint implementations
Troubleshooting Distributed Transaction Coordinator errors in SQL Server
Achieving high availability and disaster recovery with SharePoint databases
Clearing the Windows page file and its effect on server performance
Deploying a SQL Server virtual appliance for Microsoft Hyper-V
How to create SQL Server virtual appliances for Hyper-V
Push vs. pull: Configuring SQL Server replication

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
contiguity  (SearchSQLServer.com)
contiguous  (SearchSQLServer.com)
drilldown  (SearchSQLServer.com)
hashing  (SearchSQLServer.com)
hybrid online analytical processing  (SearchSQLServer.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



SQL Server Development - .NET, C#, T-SQL, Visual Basic
HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts