Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9022205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:26:51+00:00 2026-06-16T05:26:51+00:00

Here is my SQL. I cannot seem to get one single value out of

  • 0

Here is my SQL. I cannot seem to get one single value out of this thing. It only works if I remove all of the xmlns attributes.

I think the problem is that this xml contains 2 default namespaces, one attached to the Response element and one attached to the Shipment element.

DECLARE @xml XML
SET @xml = '<TrackResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Response xmlns="http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0">
    <ResponseStatus>
      <Code>1</Code>
      <Description>Success</Description>
    </ResponseStatus>
    <TransactionReference />
  </Response>
  <Shipment xmlns="http://www.ups.com/XMLSchema/XOLTWS/Track/v2.0">
    <InquiryNumber>
      <Code>01</Code>
      <Description>ShipmentIdentificationNumber</Description>
      <Value>1ZA50209234098230</Value>
    </InquiryNumber>
    <ShipperNumber>A332098</ShipperNumber>
    <ShipmentAddress>
      <Type>
        <Code>01</Code>
        <Description>Shipper Address</Description>
      </Type>
      <Address>
        <AddressLine>123 HWY X</AddressLine>
        <City>SOMETOWN</City>
        <StateProvinceCode>SW</StateProvinceCode>
        <PostalCode>20291   1234</PostalCode>
        <CountryCode>US</CountryCode>
      </Address>
    </ShipmentAddress>
    <ShipmentWeight>
      <UnitOfMeasurement>
        <Code>LBS</Code>
      </UnitOfMeasurement>
      <Weight>0.00</Weight>
    </ShipmentWeight>
    <Service>
      <Code>42</Code>
      <Description>UPS GROUND</Description>
    </Service>
    <Package>
      <TrackingNumber>1ZA50209234098230</TrackingNumber>
      <PackageServiceOption>
        <Type>
          <Code>01</Code>
          <Description>Signature Required</Description>
        </Type>
      </PackageServiceOption>
      <Activity>
        <ActivityLocation>
          <Address>
            <City>SOMEWHERE</City>
            <StateProvinceCode>PA</StateProvinceCode>
            <CountryCode>US</CountryCode>
          </Address>
        </ActivityLocation>
        <Status>
          <Type>X</Type>
          <Description>Damage reported. / Damage claim under investigation.</Description>
          <Code>UY</Code>
        </Status>
        <Date>20120424</Date>
        <Time>125000</Time>
      </Activity>
      <Activity>
        <ActivityLocation>
          <Address>
            <City>SOMEWHERE</City>
            <StateProvinceCode>PA</StateProvinceCode>
            <CountryCode>US</CountryCode>
          </Address>
        </ActivityLocation>
        <Status>
          <Type>X</Type>
          <Description>All merchandise discarded. UPS will notify the sender with details of the damage.</Description>
          <Code>GY</Code>
        </Status>
        <Date>20120423</Date>
        <Time>115500</Time>
      </Activity>
      <PackageWeight>
        <UnitOfMeasurement>
          <Code>LBS</Code>
        </UnitOfMeasurement>
        <Weight>0.00</Weight>
      </PackageWeight>
    </Package>
  </Shipment>
</TrackResponse>'

select Svc.Dsc.value('(/TrackResponse/Shipment/Service/Description)[1]', 'varchar(25)')
from @xml.nodes('/TrackResponse') as Svc(Dsc)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:26:55+00:00Added an answer on June 16, 2026 at 5:26 am

    Two problems:

    • you’re blatantly ignoring the XML namespace that’s defined on the <shipment> element
    • your XQuery expression was a bit off

    Try this:

    -- define XML namespace
    ;WITH XMLNAMESPACES('http://www.ups.com/XMLSchema/XOLTWS/Track/v2.0' AS ns)
    select 
        Svc.Dsc.value('(ns:Shipment/ns:Service/ns:Description)[1]', 'varchar(25)')
    from 
        -- this already selects all <TrackResponse> nodes - no need to repeat that in 
        -- your above call to .value()
        @xml.nodes('/TrackResponse') as Svc(Dsc)
    

    Gives me a result of:

    UPS GROUND
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange one here that I just can't seem to figure out.
This question already has an answer here: view sql that linq-to-sql produces 3 Answers
In the comments on this answer , Remou writes that CurrentDB.Execute insert sql here
SQL novice here. I'm trying to get a list of invoice numbers. There are
I have this SQL code here.. SELECT cl.clientid, cl.clientname, cl.billingdate, cp.startdate, cp.expiration, (SELECT COUNT(*)
I can’t seem to get the result I need. Here is the array as
I cannot seem to figure out what is wrong with the code for the
I have a gallery page I am working on and cannot seem to get
So I followed this guide here http://www.kodyaz.com/articles/sql-server-2005-database-encryption-step-by-step.aspx on how to setup encryption for my
I've researched this scenario for a few hours now but cannot seem to find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.