1

I've been struggling with this all afternoon, so I'm hoping someone here can help me.

I've seen several threads similar to this, but none of provided me with an answer to my exact situation.

I'm using SQL Server 2016 and I have a stored procedure (I didn't write it and can't modify it) that returns several different tables of information. I'm trying to inject the results of all of the tables into a temp table.

I've tried to go the long route and type out the exact column headers to define the "Create Table" and now I am continuously getting the error:

Warning: The join order has been enforced because a local join hint is used.

Msg 213, Level 16, State 7, Procedure spRptMgmtManagementSummary, Line 290 [Batch Start Line 0]
Column name or number of supplied values does not match table definition.

Obviously something isn't matching up, but since there are several hundred columns I'm at a loss in regards to how I can pinpoint what I'm missing. I've eyeballed it several times and can't seem to find anything missing from either table (although I supposed it could be a data type issue?).

Is there a way to match up the temp table and the store procedure to find out what I am missing?

Still fairly new at this, but it seems crazy that I can't create a table automatically based on the stored procedure outputs or export the outputs to excel in a usable format for a comparison.

Any help would be greatly appreciated!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
t25
  • 167
  • 3
  • 14
  • Possible duplicate of [Insert results of a stored procedure into a temporary table](https://stackoverflow.com/questions/653714/insert-results-of-a-stored-procedure-into-a-temporary-table) – Brien Foss Jan 24 '18 at 01:50
  • If it's one table you can use the link in the prior comment. If it returns multiple tables and you want to load them into Excel, I suggest you use VBA with MARS (multiple active result sets) to pull them in. You can also use powershell. I don't know of a way to load multiple tabular results from one stored proc into a table purely in T-SQL – Nick.Mc Jan 24 '18 at 06:52

0 Answers0