Despite best efforts to size a tempdb , on occasions 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.
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,’<enter_target_size_in_MB’>)
GO
--shrink the main log file
DBCC shrinkfile (templog, ’<enter_target_size_in_MB’>)
e.g DBCC shrinkfile (tempdev, 5000)
Method 2:DBCC SHRINKDATABASE
DBCC SHRINKDATABASE(tempdb,’<enter_target_percent>’)
e.g DBCC SHRINKDATABASE(tempdb,20)
Ref:Jack Vamvas (http://www.sqlserver-dba.com)
This is only a preview. Your comment has not yet been posted.
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.
Posted by: |