It was a late evening call from the customer that they tried to move tempdb from one drive to another and issued an alter database statement with the new file name for mdf and ldf as below. The mistake they did was to forget to post the actual mdf and ldf file name and left it up to the folder on both the files. The server took it and they also stoped the server and was unable to start the server instance.
-- wrong code, donot copy this and use
ALTER DATABASE tempdb MODIFY FILE (NAME = 'tempdev', FILENAME = 'J:\SQL2005.1\Data')
-- wrong code, donot copy this and use
ALTER DATABASE tempdb MODIFY FILE (NAME = 'templog', FILENAME = 'J:\SQL2005.1\Data')
-- correct code
ALTER DATABASE tempdb MODIFY FILE (NAME = 'tempdev', FILENAME = 'J:\SQL2005.1\Data\tempdb.mdf')
ALTER DATABASE tempdb MODIFY FILE (NAME = 'templog', FILENAME = 'J:\SQL2005.1\Data\tempdb.ldf')
We searched for online articles for a fix on this, can't find one.. I will skip all the steps which were unsuccessful here (even sqlservr -c -f -t3608 -t4022 was unsuccessful)on this article. please read further. FYI: Customer did not take backups of system databases for ever.
Fix: Steps we followed to fix the issue
1. copied a same sp2 version of the master database from one of our servers to the customer's server and placed it in the same place where the master ldf and mdf were present. (after a backup of the current master mdf and ldf)
2. moved other system databases on the client's machine to the same folder as our server's system databases (tempdb,model,msdb) and started the server.
3. removed all the databases which were not found from the database list. (since they are from our server..not customer's)
4. attached all the relevent dbs from customer.
5. now gave the correct path for temp db with file name on the alter database command as above.
6. moved the tempdb to the J drive location
7. stoped and restared the server... everything works.
Please send your comments if this document needs to be explained more. Please give your credits to this article if it was useful.. Thanks.