Insert into table the result from stored procedure plus extra columns

筅森魡賤 提交于 2019-12-14 02:17:32

问题


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 + '''')

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.


回答1:


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



来源:https://stackoverflow.com/questions/35428540/insert-into-table-the-result-from-stored-procedure-plus-extra-columns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!