I would like to return the Dimensions where the PackageUOM is 'EA'. Currently, I am only getting the first subnode, this is causing problems!
I know that I would only like to pull the dimensions if the PackageUOM is EA, I am not sure how to do this. Any help would be appreciated. Thank you.
for reference this is in SQL 2014
<Packages>
<Package MaintenanceType="A">
<PackageUOM>PL</PackageUOM>
<QuantityofEaches>50</QuantityofEaches>
<Orderable>Y</Orderable>
<Dimensions UOM="IN">
<Height>40.7500</Height>
<Width>42.0000</Width>
<Length>48.0000</Length>
</Dimensions>
</Package>
<Package MaintenanceType="A">
<PackageUOM>EA</PackageUOM>
<QuantityofEaches>1</QuantityofEaches>
<Orderable>Y</Orderable>
<Dimensions UOM="IN">
<Height>7.2500</Height>
<Width>17.0000</Width>
<Length>10.2500</Length>
</Dimensions>
<Weights UOM="PG">
<Weight>8.8400</Weight>
</Weights>
</Package>
</Packages>
SELECT *
FROM OPENXML(@handle, 'a:PIES/a:Items/a:Item',2)
WITH (
[TestFile] varchar(max) '../../a:TestFile',
[PIESVersion] varchar(max) '../../a:Header/a:PIESVersion',
[SubmissionType] varchar(max) '../../a:Header/a:SubmissionType',
[LanguageCode] varchar(max) '../../a:Header/a:LanguageCode',
[TechnicalContact] varchar(max) '../../a:Header/a:TechnicalContact',
[ContactEmail] varchar(max) '../../a:Header/a:ContactEmail',
[PCdbVersionDate] varchar(max) '../../a:Header/a:PCdbVersionDate',
[PAdbVersionDate] varchar(max) '../../a:Header/a:PAdbVersionDate',
[ItemLevelGTIN] varchar(max) 'a:ItemLevelGTIN',
[PartNumber] varchar(max) 'a:PartNumber',
[BrandAAIAID] varchar(max) 'a:BrandAAIAID',
[BrandLabel] varchar(max) 'a:BrandLabel',
[SubBrandAAIAID] varchar(max) 'a:SubBrandAAIAID',
[SubBrandLabel] varchar(max) 'a:SubBrandLabel',
[PartTerminologyID] varchar(max) 'a:PartTerminologyID',
[PackageUOM] varchar(max) 'a:Packages/a:Package/a:PackageUOM',
[PackageQuantityofEaches] varchar(max) 'a:Packages/a:Package/a:QuantityofEaches',
[PackageDimensionUOM] varchar(10) 'a:Packages/a:Package/a:Dimensions/@UOM',
[PackageHeight] decimal(9,4) 'a:Packages/a:Package/a:Dimensions/a:Height',
[PackageWidth] decimal(9,4) 'a:Packages/a:Package/a:Dimensions/a:Width',
[PackageLength] decimal(9,4) 'a:Packages/a:Package/a:Dimensions/a:Length',
[PackageWeightUOM] varchar(max) 'a:Packages/a:Package/a:Weights/@UOM',
[PackageWeight] decimal(9,4) 'a:Packages/a:Package/a:Weights/a:Weight',
[PackageUPC] varchar(max) 'a:Packages/a:Package/a:PackageLevelGTIN'
) A
WHERE A.[PartNumber]='OW7168'
SELECTstatement is not matching XML structure.