Using Database Copies for Backup and Restore

You’ve already seen how to create database copies using the CREATE DATABASE AS COPY OF command. You can also use database copying as a simple backup and restore methodology. To do this you first create a T-SQL backup script that works against your SQL databases. Next you incorporate this script into a scheduled job that executes using your local installation of SQL Agent. One example might resemble the following scenario.

Every evening your backup script creates a fresh copy of your production database, naming it with a suffix indicating the current day, month, and year (e.g., MyDatabase_12_14_2014). After accumulating the desired maximum number of copies, your script drops the oldest copy before creating ...

Get Microsoft SQL Server 2014 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.