Creating a backup of your database is essential for data protection and recovery. In SQL Server, the BACKUP DATABASE
statement is used to make a full copy of your database and store it in a specified file location.
SQL Backup DB Syntax
BACKUP DATABASE database_name TO DISK = 'file_path.bak';
SQL Backup DB Example
This command creates a full backup of the StudentRecords
database and saves it to the specified file path on the D:
drive.
BACKUP DATABASE StudentRecords TO DISK = 'D:\Backups\StudentRecords_Full.bak';
SQL Backup DB With Differential
A differential backup captures only the changes made since the last full backup. This is faster and uses less space than performing a full backup each time.
SQL Backup DB With Differential Syntax
BACKUP DATABASE database_name TO DISK = 'file_path.bak' WITH DIFFERENTIAL;
SQL Backup DB With Differential Example
This command creates a differential backup of StudentRecords
, storing only the changes made since the last full backup.
BACKUP DATABASE StudentRecords TO DISK = 'D:\Backups\StudentRecords_Diff.bak' WITH DIFFERENTIAL;
SQL Backup DB Visual Diagram
