Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi experts i have got 1 xml column in my table like this

XML
<CasteCertificate>
  <AAAAAAAA>
    <GGGG>RD1038696004993</GGGG>
    <TLIFileNo>dfug</TLIFileNo>
    <DDDDDDD>dshf</DDDDDDD>
    <TTTTT>dslf</TTTTTgt;
    <ApplicantFatherName>xcjgv</ApplicantFatherName>
    <ApplicantCAddress1>cfhk</ApplicantCAddress1>
    <ApplicantCAddress2>dfjkgh/</ApplicantCAddress2>
    <ApplicantCAddress3 />kgjhdfhf </ApplicantCAddress3 />
    <ApplicantCAddressPin>0</ApplicantCAddressPin>
  </AAAAAAAA>
</CasteCertificate>


How can i get Address field value by using sql query???
eg: I want to write a query like
Select ApplicantCAddress1, ApplicantCAddress2, ApplicantCAddress3 from *

thank you
(Keerthi Kumar)
Posted
Updated 15-Sep-14 20:48pm
v3

1 solution

You should use Google...
http://msdn.microsoft.com/en-us/library/ms178030.aspx[^]
SQL
select 
  xmlfield.value('/CasteCertificate/ApplicantCAddress1', 'varchar(max)') AS ApplicantCAddress1,
  xmlfield.value('/CasteCertificate/ApplicantCAddress2', 'varchar(max)') AS ApplicantCAddress2,
  xmlfield.value('/CasteCertificate/ApplicantCAddress3', 'varchar(max)') AS ApplicantCAddress3
from
  Table
 
Share this answer
 
Comments
Keerthi Kumar(Andar) 16-Sep-14 4:37am    
Am getting this error

Msg 2389, Level 16, State 1, Line 2
XQuery [Table_xml.value()]: 'value()' requires a singleton (or empty sequence), found operand of type 'xdt:untypedAtomic *'
Kornfeld Eliyahu Peter 16-Sep-14 4:43am    
The error hints that you have an error in your XQuery syntax...Please show your SQL...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900