0

I am calling a stored procedure like this:

usp_ReportResults @query = '759,905,1048,170,725,80129', 
 @ReportName = 'GenRepot'

where usp_ReportResult is defined as

CREATE PROCEDURE [dbo].[usp_ReportResults]
 @query VARCHAR(MAX), 
 @ReportName VARCHAR(100), 
 @AutoSelectXML BIT = 1, 
 @XMLResult XML = NULL OUTPUT

I am trying to get result in xml variable to make further process as:

DECLARE @XMLRESULT xml
SET @XMLRESULT = exec usp_ReportResults @query = '759,905,1048,170,725,80129', @ReportName = 'GenRepot'

But I'm not able to get result in @XMLRESULT and unable to read and store data result from xml to table.

Paul White
95.3k30 gold badges439 silver badges689 bronze badges
asked Jan 20, 2016 at 9:54

1 Answer 1

1

You don't need to SET the XMLRESULT.

You should pass it in as an OUTPUT parameter.

https://technet.microsoft.com/en-us/library/ms187004(v=sql.105).aspx

DECLARE @XMLRESULT xml;
EXEC usp_ReportResults @query = '759,905,1048,170,725,80129', @ReportName ='GenRepot', @XMLResult = @XMLRESULT OUTPUT;

You can then use the @XMLRESULT parameter, which has been populated with the result of the Stored Procedure.

INSERT INTO dbo.my_table(xml_field)
SELECT @XMLRESULT;
answered Jan 20, 2016 at 10:01
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.