Tuesday, July 2, 2013

Reducing the tempdb size using dbcc Shrink command in SQL Server

We can use the below code to achieve the shrink the tempdb size.

use tempdb
go

dbcc shrinkfile(tempdev, 1024)
go

dbcc shrinkfile(templog, 1024)
go

dbcc shrinkfile(tempdb2, 1024)
go

dbcc shrinkfile(tempdb3, 1024)
go

dbcc shrinkfile(tempdb4, 1024)
go

dbcc shrinkfile(tempdb5, 1024)
go

dbcc shrinkfile(tempdb6, 1024)
go

dbcc shrinkfile(tempdb7, 1024)
go

dbcc shrinkfile(tempdb8, 1024)
go