Solved

sql server moved database files now it says recovery pending

Posted on 2012-12-29
2
1,114 Views
Last Modified: 2012-12-29
I moved my database files from my C drive to my J drive, then ran this code to move the database locations.  It appeared to work, but my databases all say "Recovery Pending".  If I try to open one, I get an error that says The database HOD200301 is not accessible. (ObjectExplorer).

How can I fix this?

ALTER DATABASE  HOD200203 MODIFY FILE (NAME = HOD200203 , FILENAME = 'J:\OptionDB\HOD200203.mdf ');
ALTER DATABASE  HOD200203 MODIFY FILE (NAME = HOD200203_log , FILENAME = 'J:\OptionDB\HOD200203_log.ldf ');
0
Comment
Question by:jackjohnson44
2 Comments
 
LVL 9

Accepted Solution

by:
sognoct earned 500 total points
ID: 38730109
I usually prefer backup databases then drop db and restore in new folder

Or detach db then stop SQL service, move files then attach the db

In your case seems that alter database is done to db hod200203 while error is on db hod2002031 there is a 1 on the final .... Maybe is this the problem

Another kind of similar problem can occurr when you have moved files without stopping the service.... When I've done such things on SQL 2000 the db got corruption and had to restore a backup !!!!
0
 

Author Comment

by:jackjohnson44
ID: 38730113
I am actually detaching them all now then I am going to recreate, like you said.  Thanks!
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now