Home Forums SQL Server 2005 Administering How to get RESTORE FILELISTONLY resultset into a table? RE: How to get RESTORE FILELISTONLY resultset into a table?

  • Thanks, Lucky!

    In case anyone is copy-pasting after 16+ hours of chasing this monster, I wanted to let people know of a typo in the list.

    SourceBlocSize int

    is missing a 'k'. It should be

    SourceBlockSize int

    One more variable is missing:

    TDEThumbprint varbinary(32)

    So the script is (with a little green comment so that slow people like me can catch it) 😀

    declare @path varchar(25)

    create table #tmp

    (

    LogicalName nvarchar(128)

    ,PhysicalName nvarchar(260)

    ,Type char(1)

    ,FileGroupName nvarchar(128)

    ,Size numeric(20,0)

    ,MaxSize numeric(20,0),

    FileId tinyint,

    CreateLSN numeric(25,0),

    DropLSN numeric(25, 0),

    UniqueID uniqueidentifier,

    ReadOnlyLSN numeric(25,0),

    ReadWriteLSN numeric(25,0),

    BackupSizeInBytes bigint,

    SourceBlockSize int,

    FileGroupId int,

    LogGroupGUID uniqueidentifier,

    DifferentialBaseLSN numeric(25,0),

    DifferentialBaseGUID uniqueidentifier,

    IsReadOnly bit,

    IsPresent bit,

    TDEThumbprint varbinary(32)

    )

    set @path = 'C:\Northwind.BAK' -- File path @@@@@@

    insert #tmp

    EXEC ('restore filelistonly from disk = ''' + @path + '''')

    select * from #tmp

    go

    drop table #tmp

    The FILELISTONLY headers, should you spend an absurd amount of time chasing those as I did, are as follows:

    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)