I have the following dataset:
Index | xml
A | <book><name>A book 1</name><book>
B | <book><name>B book 1</name><book><book><name>B book 2</name><book>
And have been working with this code:
SELECT [Index],
CAST([BookResults].query('data(/Book/Name)') AS VARCHAR(max)) AS BookName,
FROM [BookCache]
What I need in the end is this table: Index | BookName
A | A Book 1
B | B Book 1
B | B Book 2
What I seem to be getting with this query is:
A | A Book 1
B | B Book 1 B Book 2
Where am I going wrong? How do I separate out the fields?