Tuesday 2 December 2014

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

While trying to shrink log file we got below error:

Use ICCSPro
GO
Alter Database XXX Set Recovery Simple
GO
DBCC SHRINKFILE ('YYYYYY', 500)
GO
Alter Database XXX Set Recovery Full
GO

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

Solution:
Use the file_id in sys.database_files instead of file name
Change  DBCC SHRINKFILE ('YYYYYY', 500)
to             DBCC SHRINKFILE (2, 500) -- Two is the file id in our database.

No comments:

Post a Comment

Number of Visitors