[dba-SQLServer]SQL-DMO question

Francisco H Tapia my.lists at verizon.net
Fri Mar 14 11:58:59 CST 2003


Arthur,
    Check BOL under the RESTORE keyword...   I think you should be able to
use this command in conjuction to SQL-DMO or the Command Object from ADO.

Sample:
RESTORE
Restores backups taken using the BACKUP command. For more information about
database back up and restore operations, see Backing Up and Restoring
Databases.

Syntax
Restore an entire database:

RESTORE DATABASE { database_name | @database_name_var }
[ FROM < backup_device > [ ,...n ] ]
[ WITH
    [ RESTRICTED_USER ]
    [ [ , ] FILE = { file_number | @file_number } ]
    [ [ , ] PASSWORD = { password | @password_variable } ]
    [ [ , ] MEDIANAME = { media_name | @media_name_variable } ]
    [ [ , ] MEDIAPASSWORD = { mediapassword | @mediapassword_variable } ]
    [ [ , ] MOVE 'logical_file_name' TO 'operating_system_file_name' ]
            [ ,...n ]
    [ [ , ] KEEP_REPLICATION ]
    [ [ , ] { NORECOVERY | RECOVERY | STANDBY =
{undo_file_name|@undo_file_name_var} } ]
    [ [ , ] { NOREWIND | REWIND } ]
    [ [ , ] { NOUNLOAD | UNLOAD } ]
    [ [ , ] REPLACE ]
    [ [ , ] RESTART ]
    [ [ , ] STATS [ = percentage ] ]
]



-Francisco
http://rcm.netfirms.com

On Friday, March 14, 2003 9:17 AM [GMT-8],
Arthur Fuller <artful at rogers.com> wrote:

: I have to provide a no-brainer solution to the following problem. The
: user will receive a CD containing a backup of the network database, a
: snapshot of some point in time. This backup must be restored to a new
: database, whose names indicates the snapshot date. It's possible
: though unlikely that said database already exists (i.e. dumb-ass user
: modified some data, changed his mind, and now wants to restore the
: original). EM will not be installed, only MSDE on (local). MSDE is
: guaranteed to be installed and running.
:
: I'm looking at the sample SQL-DMO vb project called BackRestEvents,
: trying to glean ideas from it. So far I have SQL-DMO code that
: successfully opens a connection to (local) or any other available
: server. The vb sample app has two problems:
:
: 1. Unlike EM, it bitches when you type in a new database name. Within
: EM, you can select any database, choose Restore, and enter a new
: database name, resulting in a copy of some existing database.
:
: 2. The code supplied doesn't deal with the possibility that the db
: already exists. You get a message saying that you should use the
: "force restore" argument(s) to achieve this. I'm new to the Restore
: object (and in fact to this whole hierarchy). Can you tell me how to
: code these arguments to force restore if the db exists?
:
: Advice, URLs, etc. gratefully appreciated.
:
: TIA,
: Arthur
:
: _______________________________________________
: dba-SQLServer mailing list
: dba-SQLServer at databaseadvisors.com
: http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
: http://www.databaseadvisors.com





More information about the dba-SQLServer mailing list