查询表达式下方:
SELECT distinct xmlCol.value('(//interest/@id)[1]','nvarchar(64)') FROM table1
返回所有记录的 first interest 元素的 id 列表。
但是一个 xml 可能包含多个 interest 元素。
那么,如何在 sql xquery 中获取所有记录的所有 interest 元素的不同列表?
最佳答案
select distinct T.N.value('.','nvarchar(64)')
from table1
cross apply xmlCol.nodes('//interest/@id') as T(N)
关于sql - 选择sql xquery中所有记录的所有元素x的不同列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10511461/