将存储过程的结果加上额外的列插入表中 [英] Insert into table the result from stored procedure plus extra columns

查看:23
本文介绍了将存储过程的结果加上额外的列插入表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 dbFileListOnly 表中插入更多列以及 EXEC 查询:

How to insert a few more columns into the dbFileListOnly table along with EXEC query:

INSERT INTO admindb..dbfilelistonly (path, col1, col2....)
     @path, EXEC ('RESTORE FILELISTONLY FROM DISK = ''' + @path + '''')

我不知道这是否可能.我想将数据库名称与 fileListHeader 一起保存,以便在恢复哪些文件属于给定数据库时知道.

I don't know if it is possible or not. I want to save database name along with fileListHeader so that I know while restoring which files belong to a given database.

推荐答案

OPENROWSET 是一个棘手的方法,但可能会让你感到安慰.它甚至允许将 sp 结果与其他表连接.

OPENROWSET is a tricky way but may comfort you. It allows even to join sp results with other tables.

https://msdn.microsoft.com/en-us/library/ms190312%28v=sql.120%29.aspx

这篇关于将存储过程的结果加上额外的列插入表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆