restore filelistonly from disk='D:\123.bak'  命令如何获取第一条记录,好像后面不能跟where字句。
默认搜索出来的有两条记录。我想只要第一条可以吗?
要怎么筛选?

解决方案 »

  1.   

    js_szy什么意思?给点实质的东西
      

  2.   

    restore filelistonly 没用过
    用这个试试restore filelistonly from disk='D:\123.bak'WITH FILE=1
      

  3.   


    --这个命令最多只能with file=XX--可以将输出结果导入一个临时表中,之后就自由的进行各种操作了
    create table #filelistinfo
    (
    LogicalName nvarchar(128) null,
    PhysicalName nvarchar(260) null,
    Type char(1) null,
    FileGroupName nvarchar(128) null,
    FileSize bigint null ,
    FileMaxSize Bigint null,
    FileId bigint,
    CreateLSN numeric(25,0),
    DropLSN numeric(25,0) NULL,
    UniqueID uniqueidentifier,
    ReadOnlyLSN numeric(25,0) NULL,
    ReadWriteLSN numeric(25,0) NULL,
    BackupSizeInBytes bigint,
    SourceBlockSize int,
    FileGroupID int,
    LogGroupGUID uniqueidentifier NULL,
    DifferentialBaseLSN numeric(25,0) NULL,
    DifferentialBaseGUID uniqueidentifier,
    IsReadOnly bit,
    IsPresent bit
    )declare @filelistSQL varchar(8000)
    set @filelistSQL = 'restore filelistonly from disk=''D:\123.bak''' 
    insert into #filelistinfo exec(@filelistSQL)注:临时表的结构要和restore filelistonly 命令的输出结果集相同,可能在不同的SQL版本下有所差异,注意自行调整PS:楼主,分太少了吧