Skip to content
Advertisement

How do I get a value from XML column in SQL?

So, I have a table with a large chunk of data stored in XML.

The partial XML schema (down to where I need) looks like this:

Unfortunately, I am unfamiliar with pulling from XML, and my google-fu has failed me.

I believe my problem lies with the portion that goes Applicant PersonType=”Applicant”, but am unsure how to deal with it.

Thanks for any help.

Advertisement

Answer

The xpath in its simplest form would be:

This will find the first ZipCode node anywhere inside your document. If there are multiple, just be specific (as much as you want but not any more):

DB Fiddle

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement