开发者

How do capture the result set from RESTORE FILELISTONLY FROM DISK... so I can query it?

How do I capture the output from the following SQL statement so I can query the resultset?:

RESTORE FILELISTONLY FROM 
    DISK = N''D:\Restores\MyBackup.BAK'' WITH NOUNLOAD,  
    FILE = 1

Do I need to create a temporary table and then do something like?:

INSERT #tmp EXEC 开发者_如何学Go('RESTORE FILELISTONLY FROM  
    DISK = N''D:\Restores\KevsProfilerTraces.BAK'' WITH  NOUNLOAD,  FILE = 1')

I basically want to query the LogicalName and PhysicalName columns for some management tasks.

Or is there an easier way?


If your logic is in T-SQL then the only way is using INSERT ... EXEC ... as you already have in your post. It can be a #temp table or it can be a table @variable.

Other alternatives are to move the logic out of T-SQL into CLR procedures or into SSIS workflows.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜