Operating system error 38
Published 06 February 2015
You may encounter the following error when querying an encrypted database:
Msg 823, Level 24, State 2, Line 2 The operating system returned error 38 to SQL Server during a read at offset <offset> in file <database file path>.
This error occurs when SQL Server attempts to access an encrypted database file (*.mdfe, *.ndfe or *.ldfe) and the key file is unavailable, so the file cannot be decrypted.
Resolving this error
Ensure the key file used to encrypt the database file is stored in the keys directory. By default, this is%ProgramFiles(x86)%\Red Gate\HyperBac\keys on 64-bit machines and %ProgramFiles%\Red Gate\HyperBac\keys on 32-bit machines.
You can check the keys directory from the HyperBac Configuration Manager:
From the system tray, double-click the HyperBac Configuration Manager icon to open the HyperBac Configuration Manager.
Do not stop the HyperBac Control Service.
- Select the Advanced tab.
- The Encryption Key Path is displayed under Path Values.
- If the database is suspect or recovering, take the database offline and then bring it back online. To do this:
- Right-click the database in SQL Server Management Studio (SSMS), and select Tasks > Take Offline. Then, right-click and select Tasks > Bring Online.
or, - Make sure you are connected to the master database, then run the following T-SQL statement for the database:
- Right-click the database in SQL Server Management Studio (SSMS), and select Tasks > Take Offline. Then, right-click and select Tasks > Bring Online.
ALTER DATABASE <database name> SET OFFLINE
followed by
ALTER DATABASE <database name> SET ONLINE
- For information on changing the location of the keys directory, see Moving the SQL Storage Compress index, key and log files.
- For more information on key files, see Working with key files for encrypted data.