Please start any new threads on our new 
    site at https://forums.sqlteam.com.  We've got lots of great SQL Server
    experts to answer whatever question you can come up with.
    
        
            
                
                    
                        
                            
                                | Author | 
                                
                                 Topic  | 
                             
                            
                                    | 
                                         shakerramasani 
                                        Starting Member 
                                         
                                        
                                        2 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2013-09-10 : 04:52:38
                                            
  | 
                                             
                                            
                                            | 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>	                <HardDisk Value="C:\ (NTFS)"/>        	</HardDisks>        	<LocalGroups>	        		<Group Name="Administrators">         			<Member Name="Administrator"/>         			<Member Name="whargrove"/>        		</Group>        		<Group Name="Backup Operators">        		</Group>        		<Group Name="Guests">        			<Member Name="Guest"/>        		</Group>        		<Group Name="IIS_IUSRS">         		<Member Name="IUSR"/>         		</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             LocalGroupsHow could i achieve this? | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     James K 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    3873 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2013-09-10 : 09:21:25
                                          
  | 
                                         
                                        
                                          quote: Originally posted by shakerramasani 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>	                <HardDisk Value="C:\ (NTFS)"/>        	</HardDisks>        	<LocalGroups>	        		<Group Name="Administrators">         			<Member Name="Administrator"/>         			<Member Name="whargrove"/>        		</Group>        		<Group Name="Backup Operators">        		</Group>        		<Group Name="Guests">        			<Member Name="Guest"/>        		</Group>        		<Group Name="IIS_IUSRS">         		<Member Name="IUSR"/>         		</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             LocalGroupsHow could i achieve this?
  Your sample data is not valid/well-formed XML. If you post valid XML that would make it easier for someone who can answer the question.  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |