I've been having trouble trying to restore a SQL 2005 database.
Background
The database already exists, and I wanted to restore a backup of the 'live' database to my local machine. So, I copied the file to my local machine. Then opened up Microsoft SQL Server Management Studio, selected the database and then Tasks > Restore > Database...
I obviously wanted to restore from a "device" (file), so I selected the "from device" radio button, and selected the "..." button to open the "Specify Backup" dialog. Ensuring that the Backup media was set to file, I clcked on the "add" button and located the backup file.
However, the problem comes when I clicked on the OK button. I get the following error:
The error
TITLE: Microsoft SQL Server Management Studio
------------------------------
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
ADDITIONAL INFORMATION:
Cannot open backup device '<drive>:\<path>\<backup file>.bak'. Operating system error 5(error not found).
RESTORE HEADERONLY is terminating abnormally. (Microsoft SQL Server, Error: 3201)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=3201&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
The resolution
In my investigations, I have found out a couple things. Firstly, the mapping text for the error is incorrect. It should not be "error not found", it should in fact be "access denied". This error text is the key, and since in my instance for what ever reason it is not being mapped correctly. This therefore lead me down the route that allowed me to resolve this problem.
As the correctly mapped error text indicated it's an access problem. Basically, the service that SQL is running under, needs to have security rights to the backup file. So, simply adding these rights to the backup file resolved my issue!
Conclusion
It appears to be a reasonably common problem where mapping text does not map corretly. Therefore, if you do get an error, do not rely on the error text, but the error number. In this case '5'. Further more, always make sure that if SQL is accessing files from other servers, that the service account has access to those files!