SQLDMO: howto obtain logical file names from a BAK file
From: Rocio (rocio.katsanis_at_softwareservices.net)
Date: 03/11/04
- Next message: Scott Morris: "Re: Updating to NULL instead of zero"
- Previous message: RobertS: "Re: Updating to NULL instead of zero"
- Next in thread: oj: "Re: SQLDMO: howto obtain logical file names from a BAK file"
- Reply: oj: "Re: SQLDMO: howto obtain logical file names from a BAK file"
- Messages sorted by: [ date ] [ thread ]
Date: 11 Mar 2004 10:04:30 -0800
what, how, when does a logical file name is determine for a database?
If I am restoring a db from Enterprise Manager, under the Options tab,
after I configured the device to restore from (a file), I can see the
logical filenames of both, the mdf and the ldf files.
Now, I am automating all this process into code, and the SQL-DMO
object that restores a db from a file, requires to know the logical
file names for both the mdf and ldf files, specially if I am restoring
from a BAK file that was created in another server, under a specific
folder. For the moment I am hard-coding these values since this
program will (hopefully) always run to restore the same database at
the clients site. But is it possible the logical file name could
change?
The best way would be for the program to 'read' the logical names from
the actual BAK file, but I haven't figured that out yet. Any ideas on
how to do this?
My code goes:
Private oRestore As SQLDMO.Restore2
oRestore.Action = SQLDMORestore_Database
oRestore.database = database
oRestore.Files = filename
oRestore.ReplaceDatabase = True
oRestore.RelocateFiles = "[This_DB_Logical_FIlename_dat]" & "," & _
"[C:\Program Files\Microsoft SQL Server\MSSQL\Data\" &
database & ".mdf]" & "," & _
"[This_DB_Logical_FIlename_log]" & "," & _
"[C:\Program Files\Microsoft SQL Server\MSSQL\Data\" &
database & ".ldf]"
oRestore.SQLRestore oSQLServer 'restores the db
where database, filename are strings passed to this function.
database is the name for my database, and filename is the name
(including the full pathname) of the bak file to restore.
In this case the name of the database is not the same as the logical
file name.
I need to specify oRestore.RelocateFiles in my code becasue the BAK
file comes from another SQL server, was created in another folder, so
the default values will point to the location on that server. When I
am restoring in another server, another computer.
- Next message: Scott Morris: "Re: Updating to NULL instead of zero"
- Previous message: RobertS: "Re: Updating to NULL instead of zero"
- Next in thread: oj: "Re: SQLDMO: howto obtain logical file names from a BAK file"
- Reply: oj: "Re: SQLDMO: howto obtain logical file names from a BAK file"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|