65.9K
CodeProject is changing. Read more.
Home

Backup and Restore SQL Server database

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.90/5 (6 votes)

Nov 22, 2011

CPOL
viewsIcon

41783

How to backup and restore SQL Server database schema

Say, we have a database named "Employee" in SQL Server. Now we want to backup the database and then restore the backup database file. Execute the following SQL to backup Employee to Disk:
Backup Database Employee to Disk='D\DatabaseBack\emp_backup.bak'
After successfully backup, if we want to restore the backup(.bak) file, we have to execute the following SQL:
Restore Database Employee From Disk='D\DatabaseBack\emp_backup.bak' 
Differential backups only backup the data pages that have changed since the last full backup. Following is the SQL backup command to perform a differential backup:
BACKUP DATABASE Employee
TO DISK = ‘C:\DatabaseBack\Employee .bak’
WITH DIFFERENTIAL