Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Is there was to take the output; not the reture value, retrieved from a stored procedure to a table in SQL?
So I want to essentially do this:

SQL
DECLARE @TempTable Table(field1 varchar(max),field2 varchar(max), field3 varchar(max)

INSERT @TempTable= EXECUTE dbo.sp_MySP @SomeParam --Issue is this gives xml rather than a table

SELECT * FROM @TempTable
Posted
Updated 21-Aug-13 4:47am
v2

Yes. And you're almost there. Remove the =.

INSERT @TempTable EXECUTE dbo.sp_MySP @SomeParam


"Issue is this gives xml rather than a table"

Oh, does the procedure return XML?
 
Share this answer
 
Comments
iCanDivideByZero 21-Aug-13 11:03am    
The procedure returns a integer, which is not relevant to the XML output that I am trying to retrieve...I know that the procedure returns xml output, as I can see it when it when it runs in sql management studio. I just want to be able to take that output and insert it into a temp table.
PIEBALDconsult 21-Aug-13 12:14pm    
You should have specified that in the question and showed an example of the XML.
iCanDivideByZero 21-Aug-13 11:18am    
By the way, INSERT @TempTable EXECUTE dbo.sp_MySP @SomeParam
causes the following message to appear:
"Column name or number of supplied values does not match table definition"
If you want to get output in XML format, please, see:
FOR XML (SQL Server)[^]
Use PATH Mode with FOR XML[^]
 
Share this answer
 
Comments
iCanDivideByZero 21-Aug-13 11:19am    
Im not following how these examples are relevant. I need a way to take the xml output generated by the SP and put it in a table.
PIEBALDconsult 21-Aug-13 12:13pm    
You're hosed.
iCanDivideByZero 21-Aug-13 12:54pm    
Really? So you think you its a lost cause or are you being facetious?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900