我有以下 XML:
<root>
<fields>
<field>Some Name</field>
<field>Another Name</field>
</fields>
</root>
结果我想要:
Some Name
Another Name
为此,我正在尝试执行以下查询:
DECLARE @XML XML = N'
<root>
<fields>
<field>Some Name</field>
<field>Another Name</field>
</fields>
</root>';
DECLARE @idoc INT;
EXEC sys.sp_xml_preparedocument @idoc OUTPUT, @XML;
SELECT *
FROM OPENXML(@idoc, '/root/fields',2)
WITH (Name VARCHAR(300) './field');
EXEC sys.sp_xml_removedocument @idoc;
但我只得到了第一张唱片......