码迷,mamicode.com
首页 > 数据库 > 详细

SQL Server “RESTORE FILELISTONLY” Resultset

时间:2021-04-29 11:53:00      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:column   fine   ini   strong   logical   rom   restore   nbsp   ports   

SQL Server “RESTORE FILELISTONLY” Resultset

Dead-end: SELECT INTO is nice because you don‘t have to define the table columns but it doesn‘t support EXEC.

Solution: INSERT INTO supports EXEC, but requires the table to be defined. Using the SQL 2008 definition provided by MSDN I wrote the following script:

DECLARE @fileListTable TABLE (
    [LogicalName]           NVARCHAR(128),
    [PhysicalName]          NVARCHAR(260),
    [Type]                  CHAR(1),
    [FileGroupName]         NVARCHAR(128),
    [Size]                  NUMERIC(20,0),
    [MaxSize]               NUMERIC(20,0),
    [FileID]                BIGINT,
    [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) -- remove this column if using SQL 2005
)
INSERT INTO @fileListTable EXEC(RESTORE FILELISTONLY FROM DISK = ‘‘YourBackupFile.bak‘‘‘)
SELECT * FROM @fileListTable
After SQL Server 2012 going to need to add a new column, SnapshotURL nvarchar(360), e.g. as per msdn.microsoft.com/en-us/library/ms173778.aspx, but I am unsure whether that is for SQL Server 2014 or 2016 (I think it starts in 2016...) – JonBrave Aug 25 ‘16 at 14:23

 

SQL Server “RESTORE FILELISTONLY” Resultset

标签:column   fine   ini   strong   logical   rom   restore   nbsp   ports   

原文地址:https://www.cnblogs.com/chucklu/p/14714770.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!