Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

>> sqldmo restore

 
   Database Help (Home) -> MSDE RSS
Next:  stellen jobboerse arbeitsamt ausland Masseur Mass..  
Author Message
Jonathan

External


Since: Jun 11, 2008
Posts: 9



(Msg. 1) Posted: Tue Aug 05, 2008 9:11 pm
Post subject: >> sqldmo restore
Archived from groups: microsoft>public>sqlserver>msde (more info?)

Hi, I am using VBA in an Access 2003 UI to restore a database in SQLExpress
2005.
The following code snipet fails on the line oSQLServer.ExecuteImmediate with
error -2147199229... The backup set holds a backup of a database other than
the existing 'MATTestdata' database.

The .bak file is a backup of another database MATdata and I am restoring
into a database named MATTestdata.

'Create a backup device
Dim oBackupDevice As New SQLDMO.BackupDevice
oBackupDevice.Name = NewDatabase & "Restore"
oBackupDevice.Type = SQLDMODevice_DiskDump
oBackupDevice.PhysicalLocation = backupFile
oSQLServer.BackupDevices.Add oBackupDevice

'Restore source database to new database.
Dim cmdText As String
Const SQLDMOExec_ContinueOnError As Byte = 2

cmdText = "USE MASTER " & vbNewLine & _
"RESTORE FILELISTONLY " & vbNewLine & _
"FROM " & oBackupDevice.Name & "; " & vbNewLine & _
"RESTORE DATABASE " & NewDatabase & vbNewLine & _
"FROM " & oBackupDevice.Name & vbNewLine & _
"WITH MOVE '" & SourceDatabase & "_Data' TO '" & DbPath &
NewDatabase & ".mdf'," & vbNewLine & _
"Move '" & SourceDatabase & "_Log' TO '" & DbPath & NewDatabase
& ".ldf'"

oSQLServer.ExecuteImmediate cmdText, SQLDMOExec_ContinueOnError

Problem is then, how to restore a backup of one database to another database?

Any ideas or suggestions appreciated Smile

Many thanks,
Jonathan

 >> Stay informed about: >> sqldmo restore 
Back to top
Login to vote
Andrea Montanari

External


Since: Sep 13, 2003
Posts: 498



(Msg. 2) Posted: Wed Aug 06, 2008 4:18 pm
Post subject: Re: >> sqldmo restore [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

hi,
Jonathan wrote:
> Hi, I am using VBA in an Access 2003 UI to restore a database in
> SQLExpress 2005.
> The following code snipet fails on the line
> oSQLServer.ExecuteImmediate with error -2147199229... The backup set
> holds a backup of a database other than the existing 'MATTestdata'
> database.
>
> The .bak file is a backup of another database MATdata and I am
> restoring into a database named MATTestdata.
>
> 'Create a backup device
> Dim oBackupDevice As New SQLDMO.BackupDevice
> oBackupDevice.Name = NewDatabase & "Restore"
> oBackupDevice.Type = SQLDMODevice_DiskDump
> oBackupDevice.PhysicalLocation = backupFile
> oSQLServer.BackupDevices.Add oBackupDevice
>
> 'Restore source database to new database.
> Dim cmdText As String
> Const SQLDMOExec_ContinueOnError As Byte = 2
>
> cmdText = "USE MASTER " & vbNewLine & _
> "RESTORE FILELISTONLY " & vbNewLine & _
> "FROM " & oBackupDevice.Name & "; " & vbNewLine & _
> "RESTORE DATABASE " & NewDatabase & vbNewLine & _
> "FROM " & oBackupDevice.Name & vbNewLine & _
> "WITH MOVE '" & SourceDatabase & "_Data' TO '" & DbPath &
> NewDatabase & ".mdf'," & vbNewLine & _
> "Move '" & SourceDatabase & "_Log' TO '" & DbPath &
> NewDatabase & ".ldf'"
>
> oSQLServer.ExecuteImmediate cmdText, SQLDMOExec_ContinueOnError
>
> Problem is then, how to restore a backup of one database to another
> database?
>
> Any ideas or suggestions appreciated Smile

try adding REPLACE as long as MOVE..
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz http://www.hotelsole.com
DbaMgr2k ver 0.21.1 - DbaMgr ver 0.65.1 and further SQL Tools
--------- remove DMO to reply

 >> Stay informed about: >> sqldmo restore 
Back to top
Login to vote
Jonathan

External


Since: Jun 11, 2008
Posts: 9



(Msg. 3) Posted: Wed Aug 06, 2008 4:18 pm
Post subject: Re: >> sqldmo restore [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Ahh, that's it. Thanks.

Jonathan

"Andrea Montanari" wrote:

> hi,
> Jonathan wrote:
> > Hi, I am using VBA in an Access 2003 UI to restore a database in
> > SQLExpress 2005.
> > The following code snipet fails on the line
> > oSQLServer.ExecuteImmediate with error -2147199229... The backup set
> > holds a backup of a database other than the existing 'MATTestdata'
> > database.
> >
> > The .bak file is a backup of another database MATdata and I am
> > restoring into a database named MATTestdata.
> >
> > 'Create a backup device
> > Dim oBackupDevice As New SQLDMO.BackupDevice
> > oBackupDevice.Name = NewDatabase & "Restore"
> > oBackupDevice.Type = SQLDMODevice_DiskDump
> > oBackupDevice.PhysicalLocation = backupFile
> > oSQLServer.BackupDevices.Add oBackupDevice
> >
> > 'Restore source database to new database.
> > Dim cmdText As String
> > Const SQLDMOExec_ContinueOnError As Byte = 2
> >
> > cmdText = "USE MASTER " & vbNewLine & _
> > "RESTORE FILELISTONLY " & vbNewLine & _
> > "FROM " & oBackupDevice.Name & "; " & vbNewLine & _
> > "RESTORE DATABASE " & NewDatabase & vbNewLine & _
> > "FROM " & oBackupDevice.Name & vbNewLine & _
> > "WITH MOVE '" & SourceDatabase & "_Data' TO '" & DbPath &
> > NewDatabase & ".mdf'," & vbNewLine & _
> > "Move '" & SourceDatabase & "_Log' TO '" & DbPath &
> > NewDatabase & ".ldf'"
> >
> > oSQLServer.ExecuteImmediate cmdText, SQLDMOExec_ContinueOnError
> >
> > Problem is then, how to restore a backup of one database to another
> > database?
> >
> > Any ideas or suggestions appreciated Smile
>
> try adding REPLACE as long as MOVE..
> --
> Andrea Montanari (Microsoft MVP - SQL Server)
> http://www.asql.biz http://www.hotelsole.com
> DbaMgr2k ver 0.21.1 - DbaMgr ver 0.65.1 and further SQL Tools
> --------- remove DMO to reply
>
>
>
 >> Stay informed about: >> sqldmo restore 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Restore backup set - Hi all, How can I restore a database backup set created from sql server 2005 developer edition to sql server express 2005? Vijayakumar

Install MSDE in XP - Hi all, I have a problem with MSDE installation. Here is the last part of error log. === Logging stopped: 10/10/2003 17:49:00 === MSI (c) (44:64): Note: 1: 1708 MSI (c) (44:64): Product: Microsoft SQL Server Desktop Engine -- Installation operation...

Clone SQL DB (using VB?) - Hi all, I'm having a SQL Server database called X. For testing and training, I would like to make a copy of the entire DB to Y. This copy should include all data, properties, indexes, views, etc. Unfortunately, all my attempts to automate this..

Pubs and Northwind - I have MSDE 2000 installed but don't know how to connect to pubs or northwind. Could anyone help? Running Svr 03

Password in SQL - Hi, Is there a way I can store password in SQL table as encrypted using SQL table defintion instead of writing code to do encrypt and decrypt? Thanks.
   Database Help (Home) -> MSDE All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]