By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,806 Members | 1,829 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,806 IT Pros & Developers. It's quick & easy.

programmatically restore a database

P: n/a
I recently had to find ways to programmatically backup and restore an
SQL Server Express database.
For backup, I found a one-liner stored procedure that does the job
(BACKUP DATABASE Toy to disk = 'c:\Projects\Toy.bak'.
My question is, is there something as simple for a restore operation?

Thanks in Advance

-Kostas

Apr 5 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Yes, use : RESTORE DATABASE MyNwind FROM MyNwind_1 (i've taken this from
BOL) for more involved examples check BOL
--
Jack Vamvas
___________________________________
Receive free SQL tips - www.ciquery.com/sqlserver.htm

<ks***********@yahoo.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
I recently had to find ways to programmatically backup and restore an
SQL Server Express database.
For backup, I found a one-liner stored procedure that does the job
(BACKUP DATABASE Toy to disk = 'c:\Projects\Toy.bak'.
My question is, is there something as simple for a restore operation?

Thanks in Advance

-Kostas

Apr 5 '06 #2

P: n/a
Pardon my ignorance, but what is BOL?

Apr 5 '06 #3

P: n/a
BOL is the SQL Server Books Online documentation.

Note you may need to specify additional RESTORE options in some situations.
For example, database files will be restored to the original locations by
default. If you are restoring to a machine with a different drive/folder
structure, you'll need specify different file paths using the WITH MOVE
option.

--
Hope this helps.

Dan Guzman
SQL Server MVP

<ks***********@yahoo.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
Pardon my ignorance, but what is BOL?

Apr 5 '06 #4

P: n/a
We use

RESTORE DATABASE DBName FROM DISK='d:\files\Backups\DBName.bak' WITH
REPLACE

Apr 6 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.