Re: Simpler XQuery Syntax?
- From: Bill D. <RatherBeCoding4@xxxxxxxxxxxxxxxx>
- Date: Tue, 7 Jul 2009 10:50:09 -0700
Martin:
Yes, it all works. It just seems redundant to have to restate the identical
'for' statement, once for each namespace/schema. I thought there might be a
more concise way to phrase this SELECT statement that would accomplish the
same thing.
Regards,
Bill
"Martin Honnen" wrote:
Bill D. wrote:.
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?
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'
Does
WHERE
CurrentConfig.value('
(/CurrentConfiguration/Install/V[@n = "TIER_SERVER"]/@d)[1]', 'int') = 1
and
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'
OR
CurrentConfig.value('
declare default element namespace "urn:ConfigSchema_V2";
(/CurrentConfiguration/Install/V[@n = "TIER_SERVER"]/@d)[1]', 'int') = 1
do what you want?
--
Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/
- Follow-Ups:
- Re: Simpler XQuery Syntax?
- From: Martin Honnen
- Re: Simpler XQuery Syntax?
- References:
- Simpler XQuery Syntax?
- From: Bill D.
- Re: Simpler XQuery Syntax?
- From: Martin Honnen
- Simpler XQuery Syntax?
- Prev by Date: Re: Simpler XQuery Syntax?
- Next by Date: RE: Simpler XQuery Syntax?
- Previous by thread: Re: Simpler XQuery Syntax?
- Next by thread: Re: Simpler XQuery Syntax?
- Index(es):