question

basit 1 avatar image
basit 1 asked

Is SQL Server generate LSN when we take the Full backup

Hi Team, I have a little doubt about the LSN Number. Question : Is SQL Server generate LSN when we take the Full backup ? Thanks Basit
backup
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

WilliamD avatar image
WilliamD answered
The log sequence number is a unique id assigned to all entries in the transaction log. The LSN gives an ordered list of changes to a database. E.G. 1st change to the DB gets LSN:1, the next change gets LSN:2 and so on. If you want to restore a database, the log file is re-played in the order of the LSNs, so changes always happen in the same order. Take a look [here][1] for a little more information on LSNs [1]: http://msdn.microsoft.com/en-us/library/ms190411.aspx
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

basit 1 avatar image basit 1 commented ·
William U are correct whenever there is any change in database the LSN will create. LSN will create in Trancaction Log but My Question is that is LSN will create is we take full backup
0 Likes 0 ·
WilliamD avatar image WilliamD commented ·
I don't believe that this information is written to the log file. I could be wrong though.
0 Likes 0 ·
David Wimbush avatar image
David Wimbush answered
There are LSNs in the backup file, if that's what you mean. You can see what they are like this: declare @FileName varchar(255); declare @logbak table ( BackupName nvarchar(128) , BackupDescription nvarchar(255) , BackupType smallint , ExpirationDate datetime , Compressed tinyint , Position smallint , DeviceType tinyint , UserName nvarchar(128) , ServerName nvarchar(128) , DatabaseName nvarchar(128) , DatabaseVersion int , DatabaseCreationDate datetime , BackupSize numeric(20, 0) , FirstLSN numeric(25, 0) , LastLSN numeric(25,0) , CheckpointLSN numeric(25,0) , DatabaseBackupLSN numeric(25, 0) , BackupStartDate datetime , BackupFinishDate datetime , SortOrder smallint , CodePage smallint , UnicodeLocaleId int , UnicodeComparisonStyle int , CompatibilityLevel tinyint , SoftwareVendorId int , SoftwareVersionMajor int , SoftwareVersionMinor int , SoftwareVersionBuild int , MachineName nvarchar(128) , Flags int , BindingID uniqueidentifier , RecoveryForkID uniqueidentifier , Collation nvarchar(128) , FamilyGUID uniqueidentifier , HasBulkLoggedData bit , IsSnapshot bit , IsReadOnly bit , IsSingleUser bit , HasBackupChecksums bit , IsDamaged bit , BeginsLogChain bit , HasIncompleteMetaData bit , IsForceOffline bit , IsCopyOnly bit , FirstRecoveryForkID uniqueidentifier , ForkPointLSN numeric(25, 0) null , RecoveryModel nvarchar(60) , DifferentialBaseLSN numeric(25, 0) null , DifferentialBaseGUID uniqueidentifier , BackupTypeDescription nvarchar(60) , BackupSetGUID uniqueidentifier null ); insert @logbak exec ('restore headeronly from disk = ''' + @FileName + ''''); select * from @logbak;
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Blackhawk-17 avatar image
Blackhawk-17 answered
A backup is a transaction and will be identified in the Transaction Log. A full backup will include any in-flight transactions that complete before the backup finishes. The most up to date LSN is included in the header of the backup and in SQL Server so Transaction Log backups and Differential backups can read the Transaction Log and backup their relevant data. LSNs are not a backup-specific entity but are part of the transaction processes that SQL Server utilizes.
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

WilliamD avatar image WilliamD commented ·
excellent, I knew about the header part, but not that they themselves create a transaction log entry. Does this entry appear in the restored database after the fact, or in the next backup?
0 Likes 0 ·
Blackhawk-17 avatar image Blackhawk-17 commented ·
It would be in the next backup from what I understand.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.