0

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.

Result of Sp_Help Execution

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.

Rohit Kumar
  • 776
  • 3
  • 21
  • [sp_help](https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-help-transact-sql) appears to be a feature of SQL Server—so do your screen-shots. If you are asking how to fetch table metadata in MySQL you can check out the [SHOW Syntax](https://dev.mysql.com/doc/refman/5.7/en/show.html) as well as information_schema. – Álvaro González Jun 06 '17 at 07:21
  • 1
    @ÁlvaroGonzález I need to save data from the result in tables. The above scheenshot show 7 tables, I need to insert these records in my table. – Rohit Kumar Jun 06 '17 at 07:26
  • @RohitKumar As mentioned by Alvaro Gonzalez and based on the screenshot you've uploaded, the DBMS seems to be SQL Server. **If so, please use the correct tag.** – Satwik Nadkarny Jun 06 '17 at 07:51

1 Answers1

5

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. I.e. using information_schema.columns as you say!

JeffUK
  • 4,107
  • 2
  • 20
  • 34