Recommendations:
Put TempDB on fast storage (SSD/NVMe)
Use multiple TempDB files (equal to the number of logical cores up to a maximum of 8)
This example set the TEMPDB data file to 2GB with autogrow increments of 100 MB and the TEMPDB transaction log to 10% of data file with autogrow 100 MB...
USE [master]
GO
ALTER DATABASE [tempdb] MODIFY FILE ( NAME = N'tempdev', SIZE = 2097152KB , FILEGROWTH = 102400KB )
GO
ALTER DATABASE [tempdb] MODIFY FILE ( NAME = N'templog', SIZE = 256000KB , FILEGROWTH = 102400KB )
ALTER DATABASE [tempdb] MODIFY FILE (NAME = [tempdev], FILENAME = 'T:\SQLTemp\tempdb.mdf');
ALTER DATABASE [tempdb] MODIFY FILE (NAME = [templog], FILENAME = 'T:\SQLTemp\templog.ldf');
You need to restart SQL Server for this to take effect.
IMPORTANT: Make sure the new location exists and is writable by the SQL Server service, otherwise the instance will not restart.If you mess this up the only option is to restart the instance in safe (minimal configuration) mode and correct your paths. (1)Try this, it should shrink TEMPDB leaving 10% free space .
dbcc shrinkdatabase (tempdb, 10)
If this doesn't work (which is common) restart the database instance if possible.
If you cannot restart the database instance (e.g. it's a production instance) then try these steps...
NOTE that these steps are likely to cause a level of database performance degradation similar to that caused by restarting the instance (but without the outage) as both activities result in the need to repopulate caches and buffers.CHECKPOINT;
GO
DBCC DROPCLEANBUFFERS;
GO
DBCC FREEPROCCACHE;
GO
DBCC FREESYSTEMCACHE ('ALL');
GO
DBCC FREESESSIONCACHE;
GO
DBCC SHRINKFILE (TEMPDEV, 20480);
GO
DBCC SHRINKDATABASE (TEMPDB, 10);
GO
where, in this example, 20480 is the new file size in MB