I am trying to get a substring, FIRST_NAME
, attribute value from ADDRESS_XML
column in a table using a simple select query. The column type is varbinary(1000)
.
GetXml
is a custom method defined elsewhere which works fine.
My where clause is
dbo.GetXml(ADDRESS_XML).exist('xpathExpression') = 1
Following is one row of the ADDRESS_XML column:
<PostalAddress xmlns="http://tempuri.org/PostalAddress.xsd">
<PostalAddress TITLE="Mr" FIRST_NAME="John" LAST_NAME="SMITH"
ADDRESS="207a Stratford Road, Shirley" CITY="Solihull"
COUNTY="West Midlands" POSTCODE="B90 3AH"
COUNTRY="United Kingdom" CONTACT_INFO=""
EMAIL_ADDRESS="" PHONENO="" />
</PostalAddress>
What should XPath expression be ?
I am using SQL Server 2008 R2 Express The varbinary column is storing a string as hex, which is why I am using a proprietory GetXml() method on it.