How To Shrink The Tempdb Database In Sql Server

How to shrink the tempdb database in SQL Server without restarting SQL Server Service:

USE master
GO
 
DBCC FREESYSTEMCACHE('ALL')
GO
 
USE [tempdb]
GO
DBCC SHRINKFILE (N'tempdev' , 0, TRUNCATEONLY)
GO
 
USE [tempdb]
GO
DBCC SHRINKFILE (N'templog' , 0, TRUNCATEONLY)
GO
 
USE [tempdb]
GO
DBCC SHRINKDATABASE(N'tempdb' )
GO
 
DBCC FREESYSTEMCACHE('ALL') 
GO
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License