Solved

SQL SErver 2008 automated copy/restore

Posted on 2014-01-31
4
231 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 39824175
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
ID: 39824190
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
ID: 39824205
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
ID: 39824401
thx will make my way around that :-)
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

690 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