Community
Showing results for 
Search instead for 
Do you mean 
Reply

sql script to restore .bak file

New Member
Posts: 8
Country: USA

sql script to restore .bak file

I need to write a script to restore data from .bak to .adf and .alf

i need to restore data to sql server. Need to write the script.

 

Thanks

Platinum Elite Contributor
Posts: 14,384
Country: Australia

Re: sql script to restore .bak file

No need ... There's actually a function to do this in ACTDIAG under the Tools menu
New Member
Posts: 8
Country: USA

Re: sql script to restore .bak file

Yes. But I need to write own custom script/code

Is it possible.

If yes. Then how should I proceed

Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: sql script to restore .bak file

If you read through the following kb article, you should be able to write your own bat or PS1 file.

 

http://kb.swiftpage.com/app/answers/detail/a_id/27607

 

You could also just create your own sqlcmd script using a SQL backup statement.

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

[ Edited ]

Thanks for the reply Vivek.

 

First of all I tried to write a sql script to restore data. But I am not able to restore data using that script.

I have a zip file  in which I have the .bak file

So script that I have written is

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

 

But using this script I am only able to restore data that has .mfd extension not adf extension

 

When I try to restore the database inside the zip file I get this exception.

 

{"Directory lookup for the file \"V:\\ACT\\ARAMaster.ADF\" failed with the operating system error 3(The system cannot find the path specified.).\r\nFile 'ACT_DATA' cannot be restored to 'V:\\ACT\\ARAMaster.ADF'. Use WITH MOVE to identify a valid location for the file.\r\nDirectory lookup for the file \"V:\\ACT\\ARAMaster.ALF\" failed with the operating system error 3(The system cannot find the path specified.).\r\nFile 'ACT_LOG' cannot be restored to 'V:\\ACT\\ARAMaster.ALF'. Use WITH MOVE to identify a valid location for the file.\r\nProblems were identified while planning for the RESTORE statement. Previous messages provide details.\r\nRESTORE DATABASE is terminating abnormally."}

 

Dont  know ehy this issue is coming and I don't have any dirive as V drive.

 

Please help me with this. I really need to figure this out. 

 

Also I tried to folow the steps mentioned on http://kb.swiftpage.com/app/answers/detail/a_id/27607

 

So I wrote the following command to Restore As SQL .BAK backup file

ACTDiag RestoreAs act2011demoNew C:\actdatabases\Backup\database.bak c:\ActDatabases

But again the exception is coming.

 

Need your help!!

Thanks

New Member
Posts: 8
Country: USA

Re: sql script to restore .bak file

[ Edited ]

Plz can anyone help!

How it can be done.

I just want to write a script or c# code to attach the .bak database in zip file to sql server management studio

Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: sql script to restore .bak file

Are you able to paste up the entire script?

 

Also can you confirm that the ACT7 instance is on the same machine as the restoration location and the bak location.

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

Paste the entire script?

means??

 

Yes the  ACT7 instance is on the same machine as the restoration location and the bak location.

 

Thanks,

Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: sql script to restore .bak file

Ok, I just had a quick re-read. Can yo confirm that you have extracted the BAK file out of the zip?

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. I have extracted the zip file and using the .bak file from it

Thanks,