Examples of SQL Server differential backup and Restoration

Source: Internet
Author: User
Sample Code

  --  Create Test Database  
Create Database Test
Go
Use Test
Go
-- Create test table
Create Table Test
(
ID Uniqueidentifier Default Newid (),
Summary Varchar ( 200 )
)


-- Full backup database
Backup Database Test To Disk = ' F: \ test. Bak ' With Format


-- Insert the first record to the test table
Insert Into Test Values ( Default , ' First Incremental Backup ' )


-- First Incremental Backup
Backup Database Test To Disk = ' F: \ test_one_diff.diff ' With Format, differential


-- Insert the second record to the TB table
Insert Into Test Values ( Default , ' Second Incremental Backup ' )


-- Second Incremental Backup
Backup Database Test To Disk = ' F: \ test_two_diff.diff ' With Format, differential


-- Now the full backup and the first Incremental Backup are completely restored.
Go
Use Master
-- Full Backup Recovery
Restore Database Test From Disk = ' F: \ test. Bak ' With Replace , Norecovery
-- Restore from the first Incremental Backup
Restore Database Test From Disk = ' F: \ test_one_diff.diff ' With Recovery
Go
Use Test
Go
Select * From Test



-- Now the full backup and the second Incremental Backup are completely restored.
Use Master
-- Full Backup Recovery
Restore Database Test From Disk = ' F: \ test. Bak ' With Replace , Norecovery
-- Second Incremental backup restoration
Restore Database Test From Disk = ' F: \ test_two_diff.diff ' With Recovery
Go
Use Test
Go
Select * From Test



-- Delete Test Database
Go
Use Master
Go
Drop Database Test

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.