Hi,
I want to restore a SQL Server 2005 database from a backup using the
Restore-object in SMO.
The problem is i want to restore a backup from database B as database A.
Both databases exist on the same serverinstance. Executing the restore
generates an exception because the restore does not rename B.mdf to A.mdf
automatically. And because B.mdf already exists as datafile for database B on
the same serverinstance the exception occurs.
So i have to rename B.mdf in the backupset to A.mdf during the restore.
So far, so good.
SMO provides the class RelocateFile and the Restore-object in SMO has the
property RelocateFiles.
The documentation I found says that the Restore.RelocateFiles-property needs
the RelocateFile object (thus an instance of the class), but I can't find an
example how those two items work together to rename the files during
restore-operation like WITH MOVE does in T-SQL.
Can someone be so kind and help me with this problem.
Thanks