Community
Showing results for 
Search instead for 
Do you mean 
Reply

sql script to restore .bak file

Bronze Elite Contributor
Posts: 2,118
Country: United_Kingdom

Re: sql script to restore .bak file


abhinav wrote:

 

RESTORE DATABASE demoDatabse FROM DISK='"C:\actdatabases\Backup\database.bak"

 

 


You have an extra ' before the double quotes. It should read

 

RESTORE DATABASE demoDatabse FROM DISK="C:\actdatabases\Backup\database.bak"
 
Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
New Member
Posts: 8
Country: USA

Re: sql script to restore .bak file

I mistyped it will writing

 

This is the script

 

RESTORE DATABASE demoDatabse FROM DISK='C:\actdatabases\Backup\database.bak'

 

This is having the same issue that I mentioned.

Do you have any Idea how this can be done.

 

Thanks,

Bronze Elite Contributor
Posts: 2,118
Country: United_Kingdom

Re: sql script to restore .bak file

[ Edited ]

Ok, is the name of the dB: demodatabase exactly the same as the name of the manifest of the bak file. I.e. if the bak file was created from a dB called demoDb, using the RESTORE command as above you would need to do a RESTORE DATABASE demodb FROM DISK .... Else you're going to need to a RESTORE WITH MOVE

 

*EDIT*

 

Actually thinking about it that is most probably what the problem is. The original location of the manifest file was most probably on a V:\ drive somewehre and you are working on it locally on your machine. You'll need to check the FILELIST and do a MOVE.

 

*EDIT 2*

Yeah just checked your error message. Original dB was ARAMaster from the log file. 

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
New Member
Posts: 8
Country: USA

Re: sql script to restore .bak file

Yes. Name of the database is demoDatabse.
Thanks,
Copper Super Contributor
Posts: 52
Country: United_Kingdom

Re: sql script to restore .bak file

This should do the trick.

 

 

--IN THIS EXAMPLE THE DATABASE ORIGINALLY RESIDED IN R:\ THIS SCRIPT DEMONSTRATES HOW TO IDENTIFY 
--THE ORIGINAL LOCATION AND NAME OF THE DATABASE AND THEN RESTORES THE DATABASE TO A NEW LOCATION WITH A 
--NEW NAME WITH THE CORRECT EXTENSIONS FOR AN ACT! DATABASE

--SET MASTER DB CONTEXT
use master 

--FILELISTONLY WILL SHOW YOU THE ORIGINAL FILE NAMES IF THEY'RE NOT KNOWN
RESTORE FILELISTONLY FROM DISK = 'C:\DataBackups\DBBackup.bak'

--RESTORE THE DATABASE TO THE DESIRED LOCATION WITH NEW FILE NAMES
RESTORE DATABASE testing
FROM DISK = 'C:\DataBackups\DBBackup.bak'
WITH MOVE 'testing' TO 'C:\BOOM\supernewdata.adf',
MOVE 'testing_log' TO 'C:\BOOM\supernewdata.alf'

--RENAMES THE DATABASE ITSELF
ALTER DATABASE testing MODIFY Name = supernewdata

 

Regards,

 

 

Russ