At some point, more than one tempdb file has been created, and the server core number has been exceeded, and the tempdb file is deleted so that it remains the same as the number of CPU cores. However, when the deletion, found unable to delete, reported error: Cannot delete the file "Tempdev3", because it cannot be empty (Microsoft SQL Server, error: 5042)
In this case, use the script to view data and log file usage:
SELECT db_name() asDbname,name asfilename,size/128.0 ascurrentsizemb,size/128.0 - CAST(Fileproperty(Name,'spaceused') as INT)/128.0 asFreespacemb fromsys.database_files;
Can see tempdev3 This file has been occupied a part of the space, in the actual production, may each file will be occupied, here only for experimental purposes.
In this case, you need to shrink the Tempdev3 file in tempdb, before shrinking it, you need to make sure that the file does not have temporary files such as temporary tables, so you need to delete all of them before shrinking, shrinking the script:
Use tempdb GO DBCC -- To empty "tempdev3" data file GO after the contraction is complete, delete the file with the following script: ALTER DATABASE file-to-Delete "tempdev3" Data FILEGO The excess files in tempdb are completely removed.
How SQL Server removes redundant tempdb files