I have a database with a table (Authorxmldata) and a column named XML that simply has a data type of text. It contains XML data. Below is a snippet of the data.
I am trying to create a query to select the data. This is just one row but you could simple paste it in again to make multiple rows. I suspect the format is something like this, but cannot get it to work correctly. Below in the 2nd code box is a sample of the data. Any suggestions?
Jim
I am trying to create a query to select the data. This is just one row but you could simple paste it in again to make multiple rows. I suspect the format is something like this, but cannot get it to work correctly. Below in the 2nd code box is a sample of the data. Any suggestions?
Code:
SELECT
xml.value('firstname[1]','varchar(30)') AS firstname,
xml.value('lastname[1]','varchar(30)') AS lastname,
xml.value('middlename[1]','varchar(30)') AS middlename
from xml.nodes('root/author') dbo.AuthorXMLData([xml])
Code:
<author><personaldata><names><name type="given"><nameprefix></nameprefix><firstname>Sammy</firstname><middlename></middlename><lastname>Sample</lastname><namesuffix></namesuffix><displayname>Aardema, Verna</displayname></name></names><birth><date>June 6, 1911-May 11, 2000</date><location>New Era, Michigan</location></birth><addresses><address addresstype=""><street>784 Via Del Sol</street><city>N. Ft. Myers</city><state>Florida</state><postalcode>33903</postalcode><country></country></address></addresses><contacts/><parents>Alfred E. Norberg, Dora Norberg</parents><spouse></spouse><children>Austin, Paula</children></personaldata><goal>"My aim is to select the best tales which anthropologists and missionaries in the field have collected, and get them into the hands of children. I believe that an appreciation of the folk lore of other cultures promotes respect and understanding. And if the stories teach a lesson children ought to learn, that is a plus. I want my stories to be fun for children to read, and exciting but not scary enough to give them nightmares."</goal><inquiries answer="no"></inquiries><education><educationentry><institution></institution><location></location><degree></degree><date>1929-1934</date><description>Michigan State College, A.B., major in composition & journalism, East Lansing, Michigan, 1929-1934</description></educationentry></education><career><careerentry><organization></organization><location></location><position></position><date>1934-1935</date><description>Teacher, Pentwater, Michigan, 1934-1935.</description></careerentry><careerentry><organization></organization><location></location><position></position><date>1935-1936</date><description>Teacher, Muskegon, Michigan, 1935-1936.</description></careerentry><careerentry><organization></organization><location></location><position></position><date>1951-1973</date><description>Teacher, Mona Shores Schools, Muskegon, Michgan, 1951-1973.</description></careerentry><careerentry><organization></organization><location></location><position></position><date>1949-1971</date><description>City staff correspondent,The Muskegon Chronicle daily paper, 1949-1971</description></careerentry></career><writings><writing><description>Anansi Finds a Fool Dial l992.</description><title></title><publisher></publisher><genres/><date></date></writing><writing><description>Borreguita and the Coyote Knopf 1991.</description><title></title><publisher></publisher><genres/><date>1991</date></writing><writing><description>Pedro and the Padre Dial 1991.</description><title></title><publisher></publisher><genres/><date>1991</date></writing><writing><description>Traveling to Tondo Knopf 1991.</description><title></title><publisher></publisher><genres/><date>1991</date></writing><writing><description>Rabbit Makes a Monkey of Lion Dial 1989.</description><title></title><publisher></publisher><genres/><date>1989</date></writing><writing><description>Princess Gorilla and a New Kind of Water Dial 1988.</description><title></title><publisher></publisher><genres/><date>1988</date></writing><writing><description>Bimwili and the Zimwi Dial 1985.</description><title></title><publisher></publisher><genres/><date>1985</date></writing><writing><description>Oh, Kojo! How Could You! Dial 1984.</description><title></title><publisher></publisher><genres/><date>1984</date></writing><writing><description>The Vingananee and the Tree Toad Viking 1983.</description><title></title><publisher></publisher><genres/><date>1983</date></writing><writing><description>What's So Funny, Ketu? Viking 1982.</description><title></title><publisher></publisher><genres/><date>1982</date></writing><writing><description>Bringing the Rain to Kapiti Plain Dial 1981.</description><title></title><publisher></publisher><genres/><date>1981</date></writing><writing><description>Who's in Rabbit's House? Dial 1977.</description><title></title><publisher></publisher><genres/><date>1977</date></writing><writing><description>Why Mosquitoes Buzz in People's Ears Dial 1975.</description><title></title><publisher></publisher><genres/><date>1975</date></writing><writing><description>Behind the Back of the Mountain Dial 1973.</description><title></title><publisher></publisher><genres/><date>1973</date></writing><writing><description>Tales From the Third Ear E.P. Dutton 1969.</description><title></title><publisher></publisher><genres/><date>1969</date></writing><writing><description>More Tales From the Story Hat Coward McCann 1966.</description><title></title><publisher></publisher><genres/><date>1966</date></writing><writing><description>The Sky God Stories Coward McCann 1960.</description><title></title><publisher></publisher><genres/><date>1960</date></writing><writing><description>Otwe Coward McCann 1960.</description><title></title><publisher></publisher><genres/><date>1960</date></writing><writing><description>The Na of Wa Coward McCann 1960.</description><title></title><publisher></publisher><genres/><date>1960</date></writing><writing><description>Tales From the Story Hat Coward McCann 1960.</description><title></title><publisher></publisher><genres/><date>1960</date></writing><writing><description>Misoso: Once Upon a Time Tales of Africa Knopf 1994.</description><title></title><publisher></publisher><genres/><date>1994</date></writing><writing><description>Sebgugugu the Glutton Eerdmans.</description><title></title><publisher></publisher><genres/><date></date></writing><writing><description>A Bookworm Who Hatched Owen 1993.</description><title></title><publisher></publisher><genres/><date>1993</date></writing><writing><description>This for That Dial.</description><title></title><publisher></publisher><genres/><date></date></writing></writings><mentions><mention><date></date><description>Michigan Authors, 2nd ed.</description></mention><mention><date></date><description>Something About the Author Autobiography Series, Vol.8.</description></mention><mention><date></date><description>Borreguita and the Coyote will be a Reading Rainbow Selection.</description></mention><mention><date>1992</date><description>Traveling to Tondo, ALA Notable Book, 1992.</description></mention><mention><date>1975</date><description>Why Mosquitoes Buzz in People's Ears Caldecott winner, 1975</description></mention></mentions><skills/></author>
Jim