Reinstalled Windows on my development box, forgot to backup any of my work in progress databases in SQL Server Express 2008? Can i recover anything?
I still have the files from the old install. Where do i look?
Reinstalled Windows on my development box, forgot to backup any of my work in progress databases in SQL Server Express 2008? Can i recover anything?
I still have the files from the old install. Where do i look?
The files you are looking for are .ldf and .mdf files.
By default if your database is called foobar you'll have a foobar.mdf file and a foobar_log.ldf file.
You can copy these to your new installation and use sp_attach_db from within SQL management to reattach the files. sp_attach_db was deprecated in SQL 2005, but I believe it still works in SQL 2008.
Thanks goes out to hmallett, for pointing me in the right direction.
I used this to undelete my files. Found them in C:\Program Files\Microsoft SQL Server\MSSQLEXPRESS\DATA. Undeleted my databases to an external fat32 usb drive (to remove the permissions).
Next i opened SQL Server Management Studio and used this to attach it:
EXEC sp_attach_db @dbname = N'pickyournewdatabasename', @filename1 = N'F:\TheFolderWhereYouHaveTheRecoveredDB\olddatabasename.mdf' @filename2 = N'F:\TheFolderWhereYouHaveTheRecoveredDB\olddatabasename_log.ldf'
I skipped adding the ldf log file and it generated a new one. You can add it if you want. After this step everything is up and running, you should use normal backup and restore options now.
PS. Make sure you install the same SQL Server version as the old one. If you get the 661 665 error. Go here: SQL Server Version Error. I had R2 install and the Web Platform installed R1 (bug).