Friday, 10 June 2016

XML : SQL Server - For XML Path (embed element)

INPUT:

  SELECT EmpName AS [Name],         EmpDOB       AS [Birthdate],         EmpSalary        AS [WageAmount],      Add1    AS [Address1],      Add2    AS [Address2],      Mobile  AS [Mobile]  FROM   Employee  FOR XML PATH    

OUTPUT: (which works fine)

  <Employee>  <Name>Conrad</Name>  <Birthdate>14-oct-76</BirthDate>  <WageAmount>10000</WageAmount>  <AdditionalInfo>      <Address1>Washington DC</Address1>      <Address2>DC</Address2>      <Mobile>989898989</Mobile>  </AdditionalInfo>  </Employee>    

I'm able to generate output - but i want this element to be added below mobile tag (CONTACT TYPE element - how can we add this)

  <Mobile>989898989</Mobile>  **<ContactType><mobilephone/></ContactType>**    

No comments:

Post a Comment