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

How to restore a database through command prompt

P: 2

I have a MS SQL database backup file kept at location "c:\backup_20Aug08.bak". I want to restore the database through command prompt. I am going to create batch file out of these dos commands. So that the restore process will be automated. I am using SQL express edition. Can anybody help me to guide on this?

Thanks in advance,
Oct 29 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 2,878
Am not sure if that would be possible, I mean if DOS batch file alone.

You could use OSQL to connect to SQL server and RESTORE from your backup. Setup a schedule on your OS to run this in specific time or frequency.

Or you can do it the other way, create a stored proc that will restore these backup and schedule it as daily running job. You can also set notification emails for success or failed restore.

Happy Coding!

-- CK
Oct 31 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.