SQL Server Database Recovery backup

Source: Internet
Author: User

Usually we take the method of recovering the backup, select the target database, select the source device for recovery.

As follows:




2, but this way is sometimes inconvenient, and script way will be more convenient, using the script as follows.

/*
Back up the data db to the. bak file. This bak file is then used to recover a new database dbtest.
*/
UseMaster
BACKUP DATABASEDB
to DISK = ' e: \dbtest.bak'

RESTOREfilelistonly
from DISK = ' e: \dbtest.bak ' 


RESTORE DATABASEDBTest
from DISK = ' e: \dbtest.bak '
withMOVE'DBTest'  to 'E:\Program Files\Microsoft SQL Server2005\data\dbtest.mdf',
MOVE'Dbtest_log'  to 'E:\Program Files\Microsoft SQL Server2005\data\dbtest_log.ldf',

STATS= Ten, REPLACE
GO 


STATS = 10 shows one record per completion 10%
REPLACE uses bak to recover the database, forcing the restore
Dbtest and Dbtest_log are above g:\back. The logical file in Bak

SQL Server Database Recovery backup

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.