简体   繁体   中英

How to save result of sp_help TableName in User Tables

I want to save the result of SP_HELP [TableName] in UserTable. How can it be achieved. I know this information is available in information_schema.columns table.

Sp_Help执行的结果

The purpose of this tables is to use it if any changes are done to the table. It's achievable by using information_schema.columns but is it possible using sp_help.

I don't think you can do this with just T-SQL, as INSERT...EXEC calls don't work with multiple result sets, and Microsoft don't plan on fixing it ( https://connect.microsoft.com/SQLServer/feedback/details/470881/allow-more-than-one-resultset-to-be-stored-with-insert-into-exec-syntax )

So you will need to write some sort of script to run the SP and then write the result back into the database. In which case, this answer will tell you what you need to know How do I return multiple result sets with SqlCommand?

Another option would be to reverse engineer sp_help and write a series of custom stored procedures that do each part of the process in turn. Ie using information_schema.columns as you say!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM