How to restore a SQL Server transaction log by trn a log file restores a backup

Source: Internet
Author: User
Tags mssql

Restore a full backup first, but be sure to select with Nonerecovery in the full backup (option 2nd in Enterprise Manager)

The SQL statement is:

Restore Database MyData from disk = ' C:\temp\movedb.bak ' WITH NORECOVERY

The database then becomes the recovery mode, so you can restore the trn file by adding it in one piece.

Statement is:

Restore log Mydata from disk = "D:\Program Files\Microsoft SQL Server\mssql\backup\data\data_tlog_200407290022.trn" WI TH norecovery

When you get back to the data you want, you can turn the database into a normal mode.

The statement is:

Restore log Mydata from disk = "D:\Program Files\Microsoft SQL Server\mssql\backup\data\data_tlog_200407290022.trn" WI th recovery

This will allow you to restore the data to a point in time on your spare machine.

/* Use the cursor example below */declare @pathname varchar declare vendor_cursor cursor for SELECT ' D:\XXXX\WWWW\ ' +ttttt from Test OPEN V Endor_cursorfetch NEXT from Vendor_cursor to @pathnameWHILE @ @FETCH_STATUS = 0 BEGIN restore log Mydata from disk = @pathname WITH Norecovery FETCH NEXT from Vendor_cursor to @pathname END CLOSE vendor_cursor

Original address: http://www.jianfangkk.com/sqlserver/201601/275

How to restore a SQL Server transaction log by trn a log file restores a 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.