Removing Additional Data Files from TempDB

I had a need to remove TempDB DataFiles in one of our environments.
When I ran the simple DBCC SHRINKFILE Command, I encountered following error.

DBCC SHRINKFILE: Page 4:11283400 could not be moved because it is a work table page.

DBCC SHRINKFILE (N'tempdev9' , EMPTYFILE)
GO

ALTER DATABASE [tempdb] REMOVE FILE tempdev9
GO

I was able to execute the shrinkfile successfully after this command.

DBCC DROPCLEANBUFFERS
GO
DBCC FREEPROCCACHE
GO

DBCC FREESESSIONCACHE
GO

DBCC FREESYSTEMCACHE ( 'ALL')
GO

DBCC SHRINKFILE (N'tempdev9' , EMPTYFILE)
GO

ALTER DATABASE [tempdb]  REMOVE FILE tempdev9
GO

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *