Store result of stored procedure into a variable

  • I have a stored procedure that returns XML using FOR XML Explicit. I need to use the output of this procedure in another procedure, and modify the xml output before it is saved somewhere.

    Say StoredProc1 is the one returning xml output and StoredProc2 needs to consume the output of StoredProc1

    I declared a nvarchar(max) variable and trying to saved the result of StoredProc1

    Declare @xml nvarchar(max)

    EXEC @xml = StoredProc1 @Id

    This doesn't work as expected as @xml doesn't get any value assigned or rather I would say

    EXEC @xml = StoredProc1 @Id

    outputs the entire xml whereas it should just save the xml in a variable.

    Any suggestions as to what is going wrong

  • Cross Post.. divert your replies here http://qa.sqlservercentral.com/Forums/Topic1253537-392-1.aspx

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply