Tuesday, 10 September 2013

How to insert Parent node text if child node exist?

How to insert Parent node text if child node exist?

Here is a question on XQuerying in SQL (SQL Server 2008). I have an XML
that I need to output somewhat differently, for reference:
<?xml version="1.0"encoding="UTF-8"standalone="true"?>
<Computer >
<OS Name="Microsoft Windows 7 Ultimate"
ServicePack="1"/>OS - Category, Namem, Service Pack - Property,
<HardDisks>
HardDisks - Category, Value - Save as Name in the Property table
<HardDisk Value="C:\ (NTFS)"/>
</HardDisks>
<LocalGroups>
<Group Name="Administrators"> LocalGroups - Category, Name -
Property
<Member="Administrator"/> Member - Category,
Administrator, whargrove - Property, Administrators -
Parent
<Member="whargrove"/>
</Group>
<Group Name="Backup Operators">
</Group>
<Group Name="Guests">
<Member="Guest"/>
</Group>
<Group Name="IIS_IUSRS"> LocalGroups - Category, IIS_USERS -
Property
<Member="IUSR"/> LocalGroups - Member, IUSER - Property,
IIS_USERS - Parent
</Group>
<Group Name="boinc_projects">
</Group>
</LocalGroups>
</Computer>
Need to insert data like below into my table from above xml. Here is a one
special case i.e If the node contains child node need to insert parent
node as parent in the table Parent column if child not exist need to
insert NULL.
Category Property Value Parent
OS Name WH& NULL
HardDisks Null Null Null
HardDisk Value C:\ (NTFS) HardDisks
LocalGroups Null Null Null
Group Name Administrators LocalGroups
Member Aministrator Null LocalGroups
Member whargrove Null LocalGroups
How could i achieve this?

No comments:

Post a Comment