Restore under New Name with SQL-DMO

  • Does anyone know exactly how to restore a database under a new or different name using SQL-DMO.

    I am trying to do this in VB6, and can't get it to work. I keep getting messages that a logical file is not part of the database.

    Below is part of the code I am using. Any help would be greatly appreciated.

      Set objRestore = New SQLDMO.Restore

      objRestore.Action = SQLDMORestore_Database

      objRestore.Database = CmdLineDatabase

      objRestore.FileNumber = 1

      objRestore.ReplaceDatabase = True

      objRestore.Devices = "[W104]"

      objRestore.RelocateFiles = "[NHA00_DAT],[" & App.Path & "\NHA00.mdf]," _

        & "[NHA00_LOG],[" & App.Path & "\NHA00.ldf]"

      objRestore.SQLRestore objSQLServer

      Set objRestore = Nothing

  • I've encountered problems like this before doing restores from EM, for some reason SQL seems to want you to keep the logical name of the file even though it allows you to change the physical ones.

    I tend to let things stay like that, the DB is a different name, the files are in different locations and i don't really care what the logical files are called as long as the DB is working.

    Is it esential that you change the logical filename or are you just doing it for completeness?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply