The operating system returned error 21(The device is not ready.) to SQL Server during a read at offset 0x0000000001c000 in file 'E:\SQL Database\S*****d\NewAdvWorks.mdf'. Additional messages in the SQL Server error log and system event log may provide more detail. This is a severe system-level error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.

migrated from stackoverflow.com Jan 19 '10 at 3:53

This question came from our site for professional and enthusiast programmers.

  • 0 of 7 answers accepted...... Please get in the habit of accepting the best answer provided, the one solving your problem. It's the right and polite thing to do on StackOverflow and serves as an incentive for others to continue to help those looking for answers. See: meta.stackexchange.com/questions/5234/… – marc_s Jan 18 '10 at 18:08
  • I presume that this is n error message and that you would like some help debugging, no? However, I'm having to guess here because you haven't actually written a question or request for help. Please clarify. – dmckee Jan 19 '10 at 2:52

What worked for me:

alter database [database_name] set offline

...wait a few seconds...

alter database [database_name] set online 

This is better than restarting SQL Server since restarting SQL Server takes all databases offline (not just the database that is inaccessible).

  • This solution did not work for me, got the same error when trying to take the problem database offline. After a computer restart the problem did not appear. – SimplyInk Jul 11 '16 at 5:52
  • got the error 21 error again, alter database and dbcc checkdb returns the same error 21. – SimplyInk Oct 10 '16 at 2:54
  • restart computer and problem goes away again. I suspect BitLocker, checkdisk no errors. – SimplyInk Oct 10 '16 at 3:24

I encountered this same error today. Restarting the SQL Server service fixed it.

The SQL Server Error log and the Windows Event Log showed the same error:

The operating system returned error 21(The device is not ready.) to SQL Server during a read at offset 0x00000000026000 in file 'blah.mdf'. Additional messages in the SQL Server error log and system event log may provide more detail. This is a severe system-level error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.

And:

Error: 823, Severity: 24, State: 2

After reading Robert van den Berg's answer, I would try taking the database offline and then online first if you have other databases that you need to keep online.

  • Also had to restart my SQL Server service in order to resolve this issue. – jpierson Dec 6 '16 at 16:27
  • A script to restart does not work, but when manually restarting the SQL service resolves the issue. Help will be appreciated – Rajesh Jun 19 at 16:37

First read the logs that were indicated in the error message.

Then try resetting the server, then run the DBCC CheckDB again.

  • restart worked for me, but I don't think it is the best solution. Event logs and SQL logs did not shed light on what went wrong for me. – SimplyInk Oct 10 '16 at 3:31

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.