Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to:
SQL Server
Attribute | Value |
---|---|
Product Name | SQL Server |
Event ID | 5009 |
Event Source | MSSQLSERVER |
Component | SQLEngine |
Symbolic Name | ALT_BADDISKS |
Message Text | One or more files listed in the statement could not be found or could not be initialized |
This error indicates that you specified a file name or fileID in ALTER DATABASE or DBCC SHRINK* command that could not be resolved.
Consider the following scenario:
db_file1
file as data.db_file1
file, and then you back up the transaction log for this database.In this scenario, you receive an error message that resembles the following:
Msg 5009, Level 16, State 9, Line 1 One or more files listed in the statement could not be found or could not be initialized.
This issue occurs if the logical name of the file that you try to remove is not unique in the system catalog tables. For example, this issue occurs if the file existed in the database earlier, and then the file was removed.
When you try to remove a file that has the same logical name, SQL Server tries to remove the dropped logical file. This results in the error message.
To work around this issue, follow these steps.
Note
These steps cause the file ID values to be reused.
Use the ALTER DATABASE statement to create a new logical file that has a different name and the same data type. For example, name the logical file as different_remove_file_name
instead of db_file1
, as in the following example:
ALTER DATABASE [DBNAME] ADD FILE ( NAME = N'different_remove_file_name',
FILENAME = N'D:\MSSQL.1\MSSQL\DATA\db_file1.ndf', SIZE = 1MB, MAXSIZE = 1MB)
Note
You can use any file name or any file path.
Use the ALTER DATABASE statement to remove the logical file that you created in step 1, as in the following example:
ALTER DATABASE [DBNAME] REMOVE FILE [different_remove_file_name]
Create a transaction log backup of the database.
Try to remove the logical file that is named db_file1 again.
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register today