Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error attempting to restore database

Status
Not open for further replies.

fdarkness

Programmer
Feb 17, 2006
110
CA
I'm attempting to restore a database using the following command:

RESTORE DATABASE test FROM DISK = 'G:\dbbkups\mssql\cis0\dn0r.dbu' WITH REPLACE

It got busy for about 30 seconds, then returned this error:

Code:
Server: Msg 3101, Level 16, State 2, Line 1
Exclusive access could not be obtained because the database is in use.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

I then ran each line individually in query analyzer:

Code:
use master

alter database test set single_user with rollback immediate

RESTORE DATABASE test FROM DISK = 'G:\dbbkups\mssql\cis0\dn0r.dbu'

and I got the list of following errors:
Code:
Server: Msg 5105, Level 16, State 2, Line 1
Device activation error. The physical file name 'G:\database\mssql\N000\dn0r_Data.MDF' may be incorrect.
Server: Msg 3156, Level 16, State 1, Line 1
File 'dn0r_Data' cannot be restored to 'G:\database\mssql\N000\dn0r_Data.MDF'. Use WITH MOVE to identify a valid location for the file.
Server: Msg 5105, Level 16, State 1, Line 1
Device activation error. The physical file name 'F:\DBLOGS\MSSQL\N000\dn0r_Log.LDF' may be incorrect.
Server: Msg 3156, Level 16, State 1, Line 1
File 'dn0r_Log' cannot be restored to 'F:\DBLOGS\MSSQL\N000\dn0r_Log.LDF'. Use WITH MOVE to identify a valid location for the file.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

I'm not sure what's wrong with this and why it won't run. This is set up as a Management Job in Enterprise Manager for another database (it goes to a different database besides "test" but is pulling from the same backup file) and executes every morning at 6 am.

I'm trying to execute it on a laptop that is connected remotely to the server. Might that be causing the problem? I don't see why, as I can execute the saved job from the same location without the hiccup. Any help or suggestions would be appreciated!
 
You need to use the WITH MOVE command on the RESTORE DATABASE command to move the files to a folder that exists on your machine.

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005) / MCITP Database Administrator (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top