Click to Rate and Give Feedback
TechNet
TechNet Library
SQL Server
SQL Server 2008
Database Engine
Operations
Administration
 Recovering to a Log Sequence Number...
Community Content
In this section
Statistics Annotations (0)
Collapse All/Expand All Collapse All
Other versions are also available for the following:
SQL Server 2008 Books Online (October 2009)
Recovering to a Log Sequence Number (LSN)

This topic is relevant only for databases that are using the full or bulk-logged recovery models.

SQL Server 2005 and later versions let you use a log sequence number (LSN) to define the recovery point for a restore operation. This is a specialized feature that is intended for tools vendors and is unlikely to be generally useful.

ms191459.note(en-us,SQL.100).gifNote:
For information about the requirements for restoring to a specific recovery point, see Restoring a Database to a Point Within a Backup.

By using a RESTORE statement, you can stop at or immediately before the LSN, as follows:

  • Use the WITH STOPATMARK = 'lsn:<lsn_number>' clause, where lsn:<lsnNumber> is a string that specifies that the log record that contains the specified LSN is the recovery point.
    STOPATMARK roll forwards to the LSN and includes that log record in the roll forward.
  • Use the WITH STOPBEFOREMARK = 'lsn:<lsn_number>' clause, where lsn:<lsnNumber> is a string that specifies that the log record immediately before the log record that contains the specified LSN number is the recovery point.
    STOPBEFOREMARK rolls forward to the LSN and excludes that log record from the roll forward.

Typically, a specific transaction is selected to be included or excluded. Although not required, in practice, the specified log record is a transaction-commit record.

For more information about how to use LSNs, see Log Sequence Numbers and Restore Planning.

For more information about point-in-time restores, see Restoring a Database to a Point Within a Backup.

The following example assumes that the AdventureWorks database has been changed to use the full recovery model.

RESTORE LOG AdventureWorks FROM DISK = 'c:\adventureworks_log.bak' 
WITH STOPATMARK = 'lsn:15000000040000037'
GO
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker