Simpler XQuery Syntax?
- From: Bill D. <RatherBeCoding4@xxxxxxxxxxxxxxxx>
- Date: Tue, 7 Jul 2009 08:32:19 -0700
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
.
- Follow-Ups:
- RE: Simpler XQuery Syntax?
- From: Bob
- Re: Simpler XQuery Syntax?
- From: Martin Honnen
- RE: Simpler XQuery Syntax?
- Prev by Date: Re: looooooooong record
- Next by Date: Re: Simpler XQuery Syntax?
- Previous by thread: looooooooong record
- Next by thread: Re: Simpler XQuery Syntax?
- Index(es):
Relevant Pages
|