When querying a table in a DB, SQL Server throws an exception:
The operating system returned error 2 (the system cannot find the file specified.) to SQL Server during a read at offset 0x 00000000204000 in file ' \\ServerName\xxxx.ndf '. Additional messages in the SQL Server error log and system event log could provide more detail. This is a severe system-level error condition the threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB).
It is confirmed that the. ndf file that is involved in the exception message exists in the specified path, but why does SQL Server throw an exception?
The reason is that the db on the local server, some data files are stored on the remote server, and each time the server restarts, the DB cannot connect to the remote database files due to the order of the server restarts.
At this point, choosing to restart the SQL Server Service resolves the issue. However, restarting the service causes all the DB on the instance to be restarted, too violent, to allow the specified db to be offline, wait a few seconds, and then make it online.
Use Master Go Alter database database_name set offline-- wait for several seconds Alterdatabase database_name set online
Reference doc:
DBCC CheckDB the operating system returned error (the device is not ready.)
SQL Server exception occurred: The system cannot find the file specified