Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL SErver 2008 automated copy/restore

Posted on 2014-01-31
4
Medium Priority
?
234 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 1500 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

618 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