C# Forum

Ask Question   UnAnswered
Home » Forum » C#       RSS Feeds

Retrieve values when getting xml as a input parameter in a stored procedures

  Asked By: Jayden    Date: Jul 07    Category: C#    Views: 1189

How to retrieve values , if you are getting xml as a input parameter in a stored procedures..

There are situations when we have to send xml as a input parameter, there are multiple ways to fetch values from xml..
Iam listing one of them

Take an example you are getting employee information in xml format
<Employee Code="1">
<Employee Code="2">

I want to retrieve Code and Name from Xml



1 Answer Found

Answer #1    Answered By: Freya Brown     Answered On: Jul 07

To retrive values  Employee Code & Name from xml...

Declare @tempEmp xml
set @tempEmp='<Root>
<Employee Code="1">
<Employee Code="2">

SELECT T.c.value('@Code','int'),T.c.value('Name[1]','VarChar(100)')
FROM @tempEmp.nodes('/Root/Employee') T(c)

This post is locked for further answers.