Sign Up Now!Log In
Isaac 8/9/2011 7:24:59 AM

How to read an attribute from an XML field in SQL Server 2005

This tip explains how to read an XML attribute from an XML field in sql server. Or, put another way, if we have this data:

<Receivable documentNumber="PYMNT000000000012    " documentDate="12/13/2007">
  <Description />
  <CheckNumber />
  <Items />


We want to use SQL Server 2005 to retrieve the document number (PYMNT000000000012)

The code looks like this:


Version: Unknown or N/A
Section: SQL Scripts