XML Nodes Query

Something’s that easy to forget due to the case sensitive nature of the syntax.

XML that looks like this…

<Parameters>
<Parameter Name="FirstInt">NULL</Parameter>
<Parameter Name="SecondInt">2</Parameter>
</Parameters>

and has this t-sql run against it…

SELECT
    T.c.VALUE( '@Name', 'VARCHAR(36)' ) AS Name
    , T.c.VALUE( '.', 'VARCHAR(36)' ) AS VALUE
FROM @ExecutionParameters.nodes('//Parameter') AS T(c)
WHERE T.c.VALUE( '.', 'VARCHAR(36)' ) = 'NULL'

returns a rowset that looks like…

Name      Value
FirstInt  NULL
SecondInt 2
This entry was posted in SQL Server Development, SQL Toolbox and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>