Solved

SQL SErver 2008 automated copy/restore

Posted on 2014-01-31
4
226 Views
Last Modified: 2014-01-31
Hi Experts,

I would like to copy a database and restore it on another database (on the same instance)everynight. How can I automate this?

Thx
0
Comment
Question by:dlan75
  • 2
  • 2
4 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
Comment Utility
The easiest way would just be to setup a SQL Agent job to restore the backup over the existing database. I assume you already have a job to backup the main database, so you just need to grab that file and restore over the existing "copy" database.

You might have to code to figure out the name of the backup if you are including any timestamps, or have some naming convention in place.
0
 
LVL 12

Author Comment

by:dlan75
Comment Utility
Thx for the fast repy.
Could you give me some kind of procedure?
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
Comment Utility
It's difficult to be precise without knowing the make up of your database (number of data files, log files, locations, etc), but logically you want something like the following in the step of a SQL Agent job:
RESTORE DATABASE [YourCopyDatabaseName]
    FROM FILE = N'<path_and_name_of_your_backup_file'
    WITH
         MOVE '<logical_data_file_name>' TO '<physical_path_of_file_for_your_copy_database>'
         MOVE '<logical_log_file_name>' TO '<physical_path_of_file_for_your_copy_database>'
         REPLACE

Open in new window

More detailed info on the syntax and options are here: http://technet.microsoft.com/en-us/library/ms186858.aspx

Specifically you should be looking at examples D and E towards the bottom of the page.
0
 
LVL 12

Author Comment

by:dlan75
Comment Utility
thx will make my way around that :-)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now