WITH XMLNAMESPACES ('http://blah blah' AS sp) does that really do anything?

  • I'm venturing out of my typical comfort zone this week, and have a question for when you do XQuery stuff in TSQL.

    Grant Fitchey has lots of examples on his site:

    http://www.scarydba.com/2009/03/02/more-refinements-on-the-missing-indexes-query/

    is just one of many.

    note he prefaces his queries witha CTE that references a specific xmlnamespace.

    WITH XMLNAMESPACES ('http://schemas.microsoft.com/sqlserver/2004/07/showplan' AS sp)

    SELECT ...[complex query snipped]

    so, here's my question:

    As far as i know, SQL doesn't access any web sites or anything when fiddling with my code,regardless of what that CTE is doing.

    So i naturally assume that that path must be in my SQL server somewhere...so i query what i think might be the right spot:

    select * from sys.xml_schema_namespaces

    --i find the following

    --http://www.w3.org/2001/XMLSchema

    --http://schemas.microsoft.com/sqlserver/2004/sqltypes

    --http://www.w3.org/XML/1998/namespace

    so none of them seem to be on my server....but his queries work.

    Is SQL server doing something behind my back(Bobby Bouche style?) and getting soemthing from the interwebz?

    If it's not on my machine, why include it, and why does the CTE seem to work?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • It's more about the consumption of the XML being documented than about anything else.

    It's not like an XSD, that actually allows server-level validation of your XML data, it's just a place to go to get what the names in your XML mean.

    Here's a description of it that I found reasonably clear: http://www.sitepoint.com/xml-namespaces-explained/

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Oh, and no, it's not going online behind your back to check on XML namespaces. Try using them while you're not online, in a local copy of Dev Edition for example. No connection != No use of namespaces.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply