Solved

SQL Script to restore MSSql 2005 Database

Posted on 2009-05-19
3
306 Views
Last Modified: 2012-05-07
Hi All
I'm looking for a script that will restore (and overwrite) Ms sql server 2005 database from backup file. Basically I've got two identical databases in two location (one works as backup) and I transfer backup files over night and restore them next day. It would be nice to have a script that will restore them automatically.

Please advise
0
Comment
Question by:fortres
  • 2
3 Comments
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 24423040
0
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 500 total points
ID: 24423073
<< and I transfer backup files over night and restore them next day. >>

If you would be doing the file transfer then if you specify a standard file name for the backup file, then you can

1. Save the script provided above as a *.sql file
2. Using Windows scheduler you can execute this sql file using SQLCMD scripts.

Automation is done.
0
 

Author Comment

by:fortres
ID: 24423305
Thanks for advise - I did as you said rrjegan17 but intead of windows scheduler I've used SQL server Agent and it also works fine -thanks again
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question