Home All Groups Group Topic Archive Search About

"nodes" is not a valid function, property, or field.

Author
12 Oct 2007 6:21 PM
John
I am baffled.  I can do exist(), query(), value() but nodes() is not
recognized!  What am I doing wrong?

TIA for any ideas.

DECLARE @doc XML;
SELECT @doc = '<root><data>qwerty</data><data>123456</data></root>';

DECLARE @test XML;

SELECT @test = @doc.nodes('//root/data');
SELECT @test;

Author
12 Oct 2007 6:34 PM
Bob Beauchemin
Hi John,

That's just the wrong syntax/signature for nodes. Nodes doesn't return an
XML data type, its a table-valued function that returns a table that has to
be composed with another query to return a final resultset. There should be
some examples in BOL to get you going.

Cheers,
Bob Beauchemin
SQLskills

Show quote
"John" <J***@discussions.microsoft.com> wrote in message
news:6A33CA4A-F96F-41ED-A4F2-AAE3371D838A@microsoft.com...
>
> I am baffled.  I can do exist(), query(), value() but nodes() is not
> recognized!  What am I doing wrong?
>
> TIA for any ideas.
>
> DECLARE @doc XML;
> SELECT @doc = '<root><data>qwerty</data><data>123456</data></root>';
>
> DECLARE @test XML;
>
> SELECT @test = @doc.nodes('//root/data');
> SELECT @test;
Author
12 Oct 2007 6:49 PM
John
Thanks a lot Bob.  I get it now.  What a moron I am!!



Show quote
"Bob Beauchemin" wrote:

> Hi John,
>
> That's just the wrong syntax/signature for nodes. Nodes doesn't return an
> XML data type, its a table-valued function that returns a table that has to
> be composed with another query to return a final resultset. There should be
> some examples in BOL to get you going.
>
> Cheers,
> Bob Beauchemin
> SQLskills
>
> "John" <J***@discussions.microsoft.com> wrote in message
> news:6A33CA4A-F96F-41ED-A4F2-AAE3371D838A@microsoft.com...
> >
> > I am baffled.  I can do exist(), query(), value() but nodes() is not
> > recognized!  What am I doing wrong?
> >
> > TIA for any ideas.
> >
> > DECLARE @doc XML;
> > SELECT @doc = '<root><data>qwerty</data><data>123456</data></root>';
> >
> > DECLARE @test XML;
> >
> > SELECT @test = @doc.nodes('//root/data');
> > SELECT @test;
>
>
>
Author
12 Oct 2007 6:51 PM
Kent Tegels
Hello John,

Expanding on Bob's answer:

DECLARE @doc XML;
SELECT @doc = '<root><data>qwerty</data><data>123456</data></root>';
DECLARE @test XML;
SELECT @test = (select t.c.query('.') from @doc.nodes('//root/data') as t(c)
for xml path(''),type);
SELECT @test;

Thanks!
Kent Tegels
DevelopMentor
http://staff.develop.com/ktegels/

AddThis Social Bookmark Button