SQL Server with XML and selecting child nodes

Posted by Zenox on Stack Overflow See other posts from Stack Overflow or by Zenox
Published on 2010-05-27T18:22:52Z Indexed on 2010/05/27 18:31 UTC
Read the original article Hit count: 145

Filed under:
|

I have the following XML:

<tests>
   <test>1</test>
   <test>2</test>
   <test>3</test>
</tests>

And I am trying the following query:

CREATE PROCEDURE [dbo].[test]
    @Tests xml=null
AS
BEGIN
   SELECT
      doc.col.value('(test)[1]', 'nvarchar(50)')
   FROM 
      @Tests.nodes('//tests') AS doc(col)
END

But it only returns me a value from the first

What am I missing here?

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about Xml