• I guess not. Maybe it only comes available if the log is rolledover

    I've tested this small sample, and the restore to the new db workd without a warning

    So If there were any registration, the last log-restore should fail !

    --

    create database DTEST

    go

    BACKUP DATABASE DTEST

    TO disk='c:\dtestfull.bak'

     WITH  INIT

    go

    use dtest

    go

    create table dbo.tttt(col1 int not null)

    go

    insert into dbo.tttt values(1)

    go

    backup log DTEST

    TO disk='c:\dtestLog.bak'

     WITH  INIT

    insert into dbo.tttt

    select max(col1) + 1 from dbo.tttt

    go

    insert into dbo.tttt

    select max(col1) + 1 from dbo.tttt

    go

    insert into dbo.tttt

    select max(col1) + 1 from dbo.tttt

    go

    backup log DTEST

    TO disk='c:\dtestLog.bak'

     WITH  NOINIT

    -- --

    -- -- The CREATE DATABASE process is allocating 0.63 MB on disk 'DTEST'.

    -- -- The CREATE DATABASE process is allocating 0.49 MB on disk 'DTEST_log'.

    -- -- Processed 80 pages for database 'DTEST', file 'DTEST' on file 1.

    -- -- Processed 1 pages for database 'DTEST', file 'DTEST_log' on file 1.

    -- -- BACKUP DATABASE successfully processed 81 pages in 0.057 seconds (11.515 MB/sec).

    -- --

    -- -- (1 row(s) affected)

    -- --

    -- -- Processed 1 pages for database 'DTEST', file 'DTEST_log' on file 1.

    -- -- BACKUP LOG successfully processed 1 pages in 0.030 seconds (0.221 MB/sec).

    -- --

    -- -- (1 row(s) affected)

    -- --

    -- --

    -- -- (1 row(s) affected)

    -- --

    -- --

    -- -- (1 row(s) affected)

    -- --

    -- -- Processed 1 pages for database 'DTEST', file 'DTEST_log' on file 2.

    -- -- BACKUP LOG successfully processed 1 pages in 0.030 seconds (0.051 MB/sec).

    insert into dbo.tttt

    select max(col1) + 1 from dbo.tttt

    go

    insert into dbo.tttt

    select max(col1) + 1 from dbo.tttt

    go

    insert into dbo.tttt

    select max(col1) + 1 from dbo.tttt

    go

    BACKUP LOG ddbastatistics WITH  truncate_only

    go

    insert into dbo.tttt

    select max(col1) + 1 from dbo.tttt

    go

    insert into dbo.tttt

    select max(col1) + 1 from dbo.tttt

    go

    insert into dbo.tttt

    select max(col1) + 1 from dbo.tttt

    go

    backup log DTEST

    TO disk='c:\dtestLog.bak'

     WITH  NOINIT

    go

    select max(col1) as max_col1, count(*) as No_Rows  from dbo.tttt

    use master

    go

    declare @Logbackup_Filename varchar(500)

    declare @Restore_New_DBname varchar(128)

    select @Logbackup_Filename = 'c:\dtestLog.bak'

     , @Restore_New_DBname = 'DTEST1'

    declare @RestoreDb_stmt varchar(5000)

    select @RestoreDb_stmt = 'restore database ' + @Restore_New_DBname + '

    FROM DISK = ''c:\dtestfull.bak''

     WITH MOVE N''DTEST'' TO N''U:\yourpath\Data\' + @Restore_New_DBname + '.mdf''

    , MOVE N''DTEST_log'' TO N''S:\yourpath\Log\' + @Restore_New_DBname + '_log.LDF''

        , replace

        , NoRecovery '

    exec (@RestoreDb_stmt)

    if (select isnull( object_id(N'tempdb.[dbo].[#Tmp_BackupHeaders]'), 0)) <> 0

    begin

     DROP table #Tmp_BackupHeaders

    end

    -- versie SQL2K sp3a

    create table #Tmp_BackupHeaders (

    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)

    )

    declare @SQL varchar(5000)

    set @SQL = 'RESTORE HEADERONLY FROM DISK = ''' + @Logbackup_Filename + ''' '

    insert into #Tmp_BackupHeaders

    exec (@SQL)

    declare csrRestoreLog cursor  for

    select 'print ''-- db [' + convert(varchar(128),DatabaseName) + '] -- ' + convert(varchar(15), Position)

    + ' -- LSN ' + convert(varchar(128), FirstLSN ) + ' <-> ' +  convert(varchar(128), LastLSN )

    + ' -- BackupDate ' + convert(varchar(25), BackupStartDate, 121) + ' <--> ' + convert(varchar(25), BackupFinishDate, 121)

    + ' ''' + char(13)

    + 'Restore Log ' + @Restore_New_DBname + '

    FROM DISK = ''' + @Logbackup_Filename + '''

     WITH FILE = ' + convert(varchar(15),Position) + char(13)

    + case Position when M.MAX_Position then ' , Recovery '

      else ' , NoRecovery '

     end

    -- + char(13) + 'GO'

    from #Tmp_BackupHeaders

    , (select max(Position) as MAX_Position from #Tmp_BackupHeaders ) M

    order by Position

    declare @RestoreLog_stmt varchar(5000)

    open csrRestoreLog

    FETCH NEXT FROM csrRestoreLog

     INTO @RestoreLog_stmt

    WHILE @@FETCH_STATUS = 0

    BEGIN

     exec (@RestoreLog_stmt)

     -- Volgende rij inlezen

     FETCH NEXT FROM csrRestoreLog

      INTO @RestoreLog_stmt

    END

    -- Cursor afsluiten

    CLOSE csrRestoreLog

    DEALLOCATE csrRestoreLog

    go

    select max(col1) as max_col1, count(*) as No_Rows  from DTEST1.dbo.tttt

    go

     

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me