Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 attach a database primary file

Author  Topic 

nkosi
Starting Member

2 Posts

Posted - 2010-04-10 : 07:28:55
Hi all
I know this must hae been answered before but need some help here.
Our SQL 2005 server crashed but we were able to recover the .mdf and .ldf off other disks. Can I reinstall SQL 2005 and just attach the files.
The backup is two days old and we want to recover current data
Thanks

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2010-04-10 : 08:29:24
If you have recovered the mdf and ldf - Try the following, this may work. 1)Reinstall SQL Server 2005 2)ensure you have the files places in the same drive paths as the orriginal installation 3)Firstly create the same db as empty - with the mdf and ldf in the original location 4)Stop SQL Server 5)Replace the recovered MDF and LDF over the new MDF and LDF 5)Restart SQL Server



Jack Vamvas
--------------------
http://www.ITjobfeed.com
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-04-10 : 10:24:01
and then run DBCC CHECKDB ('MyDatabase') WITH NO_INFOMSGS, DATA_PURITY to check that the database is healthy.

If they are not healthy you may still be able to take a final/"tail" TLog backup (from the re-attached files), then restore from the backup taken two days ago, and then from all Tlog backups since (including the "tail" one you just made). This assumes you are using Full (rather than "Simple") Recovery Model
Go to Top of Page

nkosi
Starting Member

2 Posts

Posted - 2010-04-10 : 12:12:31
Thanks everyone.
Worked great
Then DBCC CHECKDB showed a healthy database.
users are happy and I am happy
Go to Top of Page
   

- Advertisement -