<ROOT>
<arn>arn001</arn>
<arn>arn002</arn>
</ROOT>
尝试以下代码
SELECT
ARN.value('(//arn/text())[1]','VARCHAR(100)') AS arns --TAG
FROM
@xml.nodes('/ROOT')AS TEMPTABLE(ARN)
仅返回第一个值
答案 0 :(得分:1)
尝试这种方式:
declare @xml xml = '<ROOT>
<arn>arn001</arn>
<arn>arn002</arn>
</ROOT>'
SELECT
X.value('.','VARCHAR(100)') AS arns
FROM
@xml.nodes('/ROOT/arn')AS T(X)
<强> SQL Fiddle 强>