Subscribe

SQLServer-DBA.com Links

Subscribe to newsletter

Dba_db2_button

Powered by TypePad
SQL Server - Shrink tempdb without sql server restart

13 January,2011 by Jack Vamvas

Despite best efforts to size a tempdb ,sometimes the tempdb expands to a size as big as the drive. Because the drive is full the tempdb can no longer expand. This triggers a situation in a monitoring framework. A quick solution is required, to shrink down the tempdb . Following are 2 different methods I use , that don’t require a SQL Server restart. 

It is important to focus on the reason for continious TEMDB growth , as the problem will just reappear

 If I receive consistency errors , than I resort to a SQL Server restart , depending on the situation

 DBCC DHRINKFILE will allow you to decrease to a size smaller than the original size

Method 1: DBCC SHRINKFILE

 

Use tempdb

GO

--shrink the main data file

DBCC shrinkfile (tempdev,’)

GO

--shrink the main log file

DBCC shrinkfile (templog, ’)

 

---e.g DBCC shrinkfile (tempdev, 5000)

 Method 2:DBCC SHRINKDATABASE

  

DBCC SHRINKDATABASE(tempdb,’’)

 --e.g DBCC SHRINKDATABASE(tempdb,20)

 Related Posts

TempDB performance and strategy checklist

SQL Server – tempdb and solid state drives


Author: Jack Vamvas (http://www.sqlserver-dba.com)

******** *******

Subscribe to SQLServer-DBA.com

Latest posts delivered to you daily

Delivered by FeedBurner

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer