Database backup and restore

Source: Internet
Author: User

-- Returns a result set consisting of a list of databases and log files contained in the backup set.
-- main get logical file name
Span style= "color: #0000ff;" >use master
restore  filelistonly
   from disk =< Span style= "color: #000000;" >  ' g:\back. Bak ' &NBSP;
go< Span style= "color: #000000;" >
************************************************

Recover database with Bak, Force restore (REPLACE)
STATS = 10 shows one record per completion 10%
Dbtest and Dbtest_log are above g:\back. The logical file in Bak
*/
UseMaster
RESTOREDATABASEDb
FromDISK=‘G:\back. Bak‘
WithMOVE‘DBTest‘To‘E:\Program Files\Microsoft SQL Server2005\data\db.mdf‘,
MOVE‘Dbtest_log‘To‘E:\Program Files\Microsoft SQL Server2005\data\db_log.ldf‘,
STATS=10,REPLACE
GO
++++++++++++++++++++++++++++++++

Back up the data db to the. bak file. This bak file is then used to recover a new database dbtest.
*/
UseMaster
BACKUPDATABASEDb
ToDISK=‘G:\DBBack0930.bak‘
RESTOREFilelistonly
FromDISK=‘G:\DBBack0930.bak‘
RESTOREDATABASEDBTest
FromDISK=‘G:\DBBack0930.bak‘
WithMOVE‘DBTest‘To  e:\program  files\microsoft sql server2005\data\dbtest.mdf ' , 
  move  dbtest_log '

Source: http://www.cnblogs.com/adandelion/archive/2006/09/30/519534.html
/**//*
Recover database with Bak, Force restore (REPLACE)
STATS = 10 shows one record per completion 10%
Dbtest and Dbtest_log are above g:\back. The logical file in Bak
*/
UseMaster
RESTOREDATABASEDb
FromDISK=‘G:\back. Bak‘
WithMOVE‘DBTest‘To‘E:\Program Files\Microsoft SQL Server2005\data\db.mdf‘,
MOVE‘Dbtest_log‘To‘E:\Program Files\Microsoft SQL Server2005\data\db_log.ldf‘,
STATS=10,REPLACE
GO
++++++++++++++++++++++++++++++++

/**//*
Back up the data db to the. bak file. This bak file is then used to recover a new database dbtest.
*/
UseMaster
BACKUPDATABASEDb
ToDISK=‘G:\DBBack0930.bak‘
RESTOREFilelistonly
FromDISK=‘G:\DBBack0930.bak‘
RESTOREDATABASEDBTest
FromDISK=‘G:\DBBack0930.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'
GO
---******************************

Database backup and restore

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.