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
SQL
x
1
BACKUP DATABASE database_name
2
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.
SQL
1
1
BACKUP DATABASE StudentRecords
2
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
SQL
1
1
BACKUP DATABASE database_name
2
TO DISK = 'file_path.bak'
3
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.
SQL
1
1
BACKUP DATABASE StudentRecords
2
TO DISK = 'D:\Backups\StudentRecords_Diff.bak'
3
WITH DIFFERENTIAL;
SQL Backup DB Visual Diagram
