Could not locate file 'mydatabase' for database 'mydatabase' in sys.database_files. The file either does not exist, or was dropped

 

 

Could not locate file 'mydatabase' for database 'mydatabase' in sys.database_files. The file either does not exist, or was dropped

18 October 2022

02:54

dbcc shrinkfile('mydatabase',113311) fails with following error

Could not locate file 'mydatabase' for database 'mydatabase' in sys.database_files. The file either does not exist, or was dropped

 

I managed to resolve it by renaming the logical name of the log file:

USE [clientdatabase];
ALTERDATABASE clientdatabase MODIFY FILE
(NAME =clientdatabase_log, NEWNAME =clientdatabase_log_1);

Running the script

USE [clientTdatawarehouse]
GO
DBCC SHRINKFILE (clientTDataWarehouse_log_1, 1024)
GO

 

From <https://stackoverflow.com/questions/12644312/could-not-locate-file-mydatabase-for-database-mydatabase-in-sys-database-fil>

 

Created with OneNote.

No comments:

Post a Comment

Removing tiered storage spaces - Windows Server 2022

As part of the work I have done in my homelab with tiered storage on Server 2022 storage spaces , here is a script I created that allows you...