Wednesday, 12 October 2016

XML : how to convert stored procedure result as xml to use it as sub node in another proc result

I have a stored procedure named as

  usp_Employee_GetInfo    

this proc returns a table after execution. like below:

  Id Name DeptID  1  AAA  10    

I want create a new procedure which returns xml after execution. And it includes the above proc result as one sub node like below:

  <company Name="XXX">   <Emp>     <Id>1</Id>     <Name>AAA</Name>     <DeptID>10</DeptID>   </Emp>  </company>  <company Name="YYY">   <Emp>     <Id>2</Id>     <Name>BBB</Name>     <DeptID>20</DeptID>   </Emp>  </company>    

Can u please suggest the best way to use existing proc with out disturbing to get the required output. Thank u.

No comments:

Post a Comment