XML Query Attributes

  • I assume that you actually want where the name attribute is "FirstAttributeName" since there is nothing named "FirstAttribute" in your sample.

    This should give you what you want.

    SELECT per.value('(Data/item[@name="FirstAttributeName"])[1]', 'varchar(50)') AS FirstAttribute

    You will still need to use the [1] since the value() function requires a singleton.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • That was exactly the example I was looking for THANK YOU! I was having a hard time finding an example that shows how to reference the Attribute Name.

Viewing 2 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply