Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
下面的查询表达式:
SELECT distinct xmlCol.value('(//interest/@id)[1]','nvarchar(64)') FROM table1
返回所有记录的第一个感兴趣元素的id列表。
但是一个 xml 可能包含多个 兴趣元素。
那么,如何在 sql xquery 中获取所有记录的所有兴趣元素的不同列表?
select distinct T.N.value('.','nvarchar(64)') from table1 cross apply xmlCol.nodes('//interest/@id') as T(N)