Simpler XQuery Syntax?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



All:

In SQL 2005, I’ve got an XML column called ‘CurrentConfig’ in a table called
‘Computers’. I just added a second schema to the schema collection. The
initial schema had no associated namespace (i.e. the “no namespace”
namespace). I recently added an extended schema with the namespace,
‘urn:ConfigSchema_V2’. The second schema is similar to the first, but has
been extended and tightened down in certain areas.

Look at the query below and notice that the ‘for’ statements are identical;
the only difference is the namespace declaration in the second query. This
works as intended, but it seems like a more concise representation of this
whole statement would be possible. However, I couldn’t get the syntax gods
to cooperate. ;-)

Any simplification ideas?

Thanks,
Bill D.


SELECT ComputerName
from dbo.Computers
where
cast(CurrentConfig.query('

for $x in /CurrentConfiguration/Install/V
where string($x/@n) = "TIER_SERVER"
return data($x/@d)
') as varchar(1)) = '1'

Or

cast(CurrentConfig.query('
declare default element namespace "urn:ConfigSchema_V2";

for $x in /CurrentConfiguration/Install/V
where string($x/@n) = "TIER_SERVER"
return data($x/@d)
') as varchar(1)) = '1'
ORDER BY 1
FOR XML AUTO

.



Relevant Pages

  • RE: Simpler XQuery Syntax?
    ... "Bill D." ... I just added a second schema to the schema collection. ... I recently added an extended schema with the namespace, ...
    (microsoft.public.sqlserver.xml)
  • Re: validating xml doc with multiple schemas using wildcards
    ... The second schema defines elements in the namespace ... You need to provide the locations of the schemas with schemaLocation, not with noNamespaceSchemaLocation e.g. ...
    (microsoft.public.dotnet.xml)
  • Re: Flat File Problem
    ... It was the namespace I was using to ... When I debug the orchestration the RecCount variable is null. ... Have you deployed the Biztalk Assembly that contains the property schema ... And you can promote properties from the Header into the message context, ...
    (microsoft.public.biztalk.general)
  • Schema versioning / namespace or no namespace / like root nodes / Pipelines - any ideas?
    ... Namespace Options: Trying to figure out which way to go... ... I'm planning to handle the varying levels of schema content being ... Pipeline component to add this namespace to incoming SAP docs. ... pipeline per assembly-version (since there's no need for the pipeline ...
    (microsoft.public.biztalk.general)
  • Re: Re: Re: SQLXML Namespaces
    ... > namespace, so SQLXML has declared an arbitrary prefix for the ... > the results you can declare any prefix you like and the XML ... >> Your schema must have a default or target namespace ...
    (microsoft.public.sqlserver.xml)