Home All Groups Group Topic Archive Search About

SQLDMO:To Change Database file Location path of DBBackup file ( VC

Author
17 Dec 2005 11:45 AM
Inthi
Dear all
I am creating a tool in VC7.0 for database restoration
I am facing a problem while working with sql dmo objects i need to restore
a database, which has database location as "C:\Program Files\Microsoft SQL
Server\MSSQL\Data\Sample.mdf" to new instance of SQlserver called as
NEWINSTANCE.

If i try to restore the database file with out modifying the location path
then my restoration process is failing since "C:\Program Files\Microsoft SQL
Server\MSSQL\Data\" does not exist in the new machine.

So i need to change the database location file path as given below
"C:\Program Files\Microsoft SQL Server\MSSQL$NEWINSTANCE\Data\Sample.mdf"
but i am not able to figure out how to achive it
can any one please help me out to solve the problem

waiting in message loop for response message

With Regards

Author
17 Dec 2005 12:10 PM
Tom Moreau
From the BOL:

When creating a string directing physical file relocation, build the string
as the current logical name of the database file, then the new operating
system file name. Repeat pairings of logical name and physical name until
all files implementing the database are specified. For example:

oRestore.RelocateFiles = "[Northwind1]" + "," + "[D:\Data\North_1.mdf]" _
    + "," + "[Northwind2]" + "," + "[D:\Data\North_2.mdf]"
Also, check out "Using SQL-DMO Multistrings" in the BOL.
--
    Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON   Canada  t**@cips.ca
www.pinpub.com

Show quote
"Inthi" <In***@discussions.microsoft.com> wrote in message
news:11D8A6E2-8522-4A3A-BCD5-89EC8E6F8C4C@microsoft.com...
> Dear all
> I am creating a tool in VC7.0 for database restoration
> I am facing a problem while working with sql dmo objects i need to restore
> a database, which has database location as "C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\Sample.mdf" to new instance of SQlserver called as
> NEWINSTANCE.
>
> If i try to restore the database file with out modifying the location path
> then my restoration process is failing since "C:\Program Files\Microsoft
> SQL
> Server\MSSQL\Data\" does not exist in the new machine.
>
> So i need to change the database location file path as given below
> "C:\Program Files\Microsoft SQL Server\MSSQL$NEWINSTANCE\Data\Sample.mdf"
> but i am not able to figure out how to achive it
> can any one please help me out to solve the problem
>
> waiting in message loop for response message
>
> With Regards
>

AddThis Social Bookmark Button