Backup a Database Using TSQL
Published: Jan 27, 2014
This is actually the cleanest and quickest way to produce a backup as it is a one line command in the form of:

BACKUP DATABASE <database_name> TO DISK = <backup_device>

In this following example I want to make a backup of the boredDBA database to a folder on my C drive:

backup database boredDBA to disk = 'c:\backup\boredDBA.bak'

This produces a full backup of the boredDBA database. The following are the commands to perform a Differential and Transactional backup respectively:

backup database boredDBA to disk = 'c:\backup\boredDBA.dif' with differential

backup log boredDBA to disk = 'c:\backup\boredDBA.trn'

As you can see, it’s very simple to perform your backups with scripts and therefore with just a few tweaks (maybe adding a timestamp to your backup file name, for example) you can quickly create a simple scheduled task to run your custom backup strategies.

Leave a Comment
Your email address will not be published. All fields are mandatory.
NB: Comments will only appear once they have been moderated.

Your SQL Trainer
Kevin Urquhart

I am a SQL Server DBA, Architect, Developer, and Trainer for SQL Training. This is my blog in which I’m simply trying to share my SQL knowledge and experiences with the world.

Kevin Urquhart
SQL Server Consultant, London



Copyright © 2018 London SQL Server Training Courses @ SQL Training | Website Design From Scott Heron