Friday, March 30, 2012

Restore.RelocateFiles

Hi,

I'm trying to restore a *.bak file into a different database.

Old Database SVW_TEST (from where the *.bak file is):

SVW_TEST_DATA - d:\SVW_TEST_DATA.mdf
SVW_TEST_DATA - d:\SVW_TEST_LOG.ldf

New Database SVW (to restore to):

SVW_DATA - d:\SVW_DATA.mdf
SVW_DATA - d:\SVW_LOG.ldf

I used the following code:

Dim pRestore As New Restore

pRestore.Action = SQLDMORestore_Database
pRestore.Database = "SVW"
pRestore.ReplaceDatabase = True

pRestore.Files = "D:\SVW_TEST.bak"

pRestore.RelocateFiles = "SVW_Test_Data, D:\SVW_DATA.mdf, SVW_TEST_LOG, D:\SVW_LOG.ldf"

pRestore.SQLRestore pServer

But it would work: I get an error saying that "The logical file 'SQL' is not part of the SVW-Database". Why 'SQL' ??
I also tried this version:

pRestore.RelocateFiles = "SVW_Data, D:\SVW_DATA.mdf, SVW_LOG, D:\SVW_LOG.ldf"

There I get an error saying that "The logical file 'SVW_DATA' is not part of the SVW-Database".

Can someone please help.I found the problem myself. I just had to put [] arround the names:

pRestore.RelocateFiles = "[SVW_Test_Data], [D:\SVW_DATA.mdf], [SVW_TEST_LOG], [D:\SVW_LOG.ldf]"

eventhough in some examples i found, it was with out them......

No comments:

Post a Comment