1
我有以下數據集:轉換TSQL XML領域的多個列
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>
並已與該代碼的工作:
SELECT [Index],
CAST([BookResults].query('data(/Book/Name)') AS VARCHAR(max)) AS BookName,
FROM [BookCache]
我需要的到底是該表: 指數| BOOKNAME
A | A Book 1
B | B Book 1
B | B Book 2
我似乎與這個查詢越來越是:
A | A Book 1
B | B Book 1 B Book 2
我要去哪裏錯了?如何分離出這些字段?
你能提供,你抓住了這個來自!?這正是我一直在尋找的!谷歌似乎只是給我帶來了一堆垃圾! – Volearix
哈哈:)我從接受的答案得到的例子:http://stackoverflow.com/questions/10344553/how-can-i-query-a-value-in-sql-server-xml-column – Stephan