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"
>
<
Type
>PAYMENT</
Type
>
<
CashType
>CHECK</
CashType
>
<
Description
/>
<
CheckNumber
/>
<
Amount
>3.00000</
Amount
>
<
AppliedAmount
>3.00000</
AppliedAmount
>
<
UnappliedAmount
>0.00000</
UnappliedAmount
>
<
Items
/>
</
Receivable
>
We want to use SQL Server 2005 to retrieve the document number (PYMNT000000000012)
The code looks like this: