Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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.

share|improve this answer
up vote 0 down vote accepted

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).

share|improve this answer
    
Dont use this command too often. See here weblogs.sqlteam.com/dang/archive/2009/01/18/… –  unmircea Jul 8 '10 at 17:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.