Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Could not locate file in sys.database_files Expand / Collapse
Author
Message
Posted Tuesday, October 9, 2012 3:46 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, October 6, 2014 7:17 AM
Points: 1,379, Visits: 2,690
Hi All

I had a weird situation this morning

On one of my test systems, I tried running the following command to shrink my log file
DBCC shrinkfile(filename,1024)

I received this error
Could not locate file 'filename' for database 'database_name' in sys.database_files. The file either does not exist, or was dropped.

I checked and the file does exist.

I ran a full Consistency Check (DBCC CHECKDB) and that seems to have fixed the problem.

Has anyone else come across this before? Should I be worried?

Thanks
Post #1370267
Posted Wednesday, October 10, 2012 2:26 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 2:36 AM
Points: 2,840, Visits: 3,970
My guess is, you would be using wrong file name

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done
Post #1370759
Posted Wednesday, October 10, 2012 3:18 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Yesterday @ 12:20 AM
Points: 81, Visits: 929
Use the following command:
SELECT file_id,name ,size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0 AS AvailableSpaceInMB
FROM sys.database_files;

after this command u will find the file id which has free space then run DBCC shrinkfile(file id)
Post #1370781
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse