Skip to content

Instantly share code, notes, and snippets.

Created September 2, 2016 00:42
Show Gist options
  • Save anonymous/f17e882b788e0fcf610d662c5398de1d to your computer and use it in GitHub Desktop.
Save anonymous/f17e882b788e0fcf610d662c5398de1d to your computer and use it in GitHub Desktop.
-- Let's get all Persons
SELECT t.Person.value('*:ID[1]', 'INT') AS [ID],
t.Person.value('*:Name[1]', 'VARCHAR(50)') AS [NAME],
t.Person.value('*:DOB[1]', 'DATE') AS [DOB],
t.Person.value('*:Address[1]', 'VARCHAR(50)') AS [ADDRESS],
t.Person.value('*:Vehicles[1]/*:Vehicle[1]', 'VARCHAR(50)') AS [VEHICLE1],
t.Person.value('*:Vehicles[1]/*:Vehicle[2]', 'VARCHAR(50)') AS [VEHICLE2]
FROM @XML.nodes('*:People/*:Person') AS t(Person)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment