I had a situation where a SQL Server 2016 install did not install correctly. The install completed but when I tried to move the tempdb datafiles over to a separate LUN, it created new files, leaving the old ones in place and active, so I ended up with 16 active tempdb datafiles. Here is how I removed the old 8 datafiles still on the D: drive
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
USE tempdb GO -- to empty "tempdev12" data file first. It won't delete unless it is empty. DBCC SHRINKFILE (temp2, EMPTYFILE); DBCC SHRINKFILE (temp3, EMPTYFILE); DBCC SHRINKFILE (temp4, EMPTYFILE); DBCC SHRINKFILE (temp5, EMPTYFILE); DBCC SHRINKFILE (temp6, EMPTYFILE); DBCC SHRINKFILE (temp7, EMPTYFILE); DBCC SHRINKFILE (temp8, EMPTYFILE); GO ALTER DATABASE tempdb REMOVE FILE temp2; ALTER DATABASE tempdb REMOVE FILE temp3; ALTER DATABASE tempdb REMOVE FILE temp4; ALTER DATABASE tempdb REMOVE FILE temp5; ALTER DATABASE tempdb REMOVE FILE temp6; ALTER DATABASE tempdb REMOVE FILE temp7; ALTER DATABASE tempdb REMOVE FILE temp8; GO |
Views – 2517