XML : How can I query a value from SQL Server XML column

I have following XML stored in a XML column in a SQL Server database table.

  <MachineInfo>    <OperatingSystem Caption="Microsoft Windows Server 2008 R2 Enterprise " InstallDate="2012-10-09T07:59:23Z" LastBootUpTime="2013-11-13T11:53:22Z" Manufacturer="Microsoft Corporation" OperatingSystemSKU="10" Organization="Organization" OSLanguage="1033" OSProductSuite="274" OSType="18" SerialNumber="00000-001-0000000-00000" ServicePackMajorVersion="1" ServicePackMinorVersion="0" Version="6.1.7601" WindowsDirectory="C:\Windows" />    <ComputerSystem Caption="SERVERNAME" DNSHostName="servername" Domain="test.testdomain.com" DomainRole="4" Manufacturer="VMware, Inc." Model="VMware Virtual Platform" NumberOfLogicalProcessors="1" NumberOfProcessors="1" PartOfDomain="1" Roles="[ LM_Workstation ][ LM_Server ][ Backup_Domain_Controller ][ NT ][ Backup_Browser ][ DFS ]" SystemType="x64-based PC" TotalPhysicalMemory="4294500352" Workgroup="" />    <Processors>      <Processor AddressWidth="64" Architecture="9" Caption="Intel64 Family 6 Model 37 Stepping 1" DataWidth="64" ExtClock="" Family="2" L2CacheSize="0" L2CacheSpeed="" L3CacheSize="0" L3CacheSpeed="0" Manufacturer="GenuineIntel" MaxClockSpeed="3059" Name="Intel(R) Xeon(R) CPU           X5675  @ 3.07GHz" NumberOfCores="1" NumberOfLogicalProcessors="1" OtherFamilyDescription="" ProcessorId="0FABFBFF00020651" ProcessorType="3" Revision="9473" Stepping="" UniqueId="" Version="" VoltageCaps="2" />    </Processors>    <TimeZone Bias="0" Caption="(UTC) Dublin, Edinburgh, Lisbon, London" />    <DiskDrives>      <DiskDrive DeviceID="\\.\PHYSICALDRIVE0" InterfaceType="SCSI" Manufacturer="(Standard disk drives)" Model="VMware Virtual disk SCSI Disk Device" Partitions="2" Size="42944186880" />      <DiskDrive DeviceID="\\.\PHYSICALDRIVE1" InterfaceType="SCSI" Manufacturer="(Standard disk drives)" Model="VMware Virtual disk SCSI Disk Device" Partitions="3" Size="42944186880" />    </DiskDrives>  </MachineInfo>    

I'd like to get value of ComputerSystem Caption"

No comments:

Post a Comment