我试图在sql server中解析下面的xml以获取所有3个Ids
<Configuration> <ID>1000</ID> <ID>1001</ID> <ID>1002</ID> </Configuration>
使用查询
SELECT CONFIGURATION.value('/','varchar(200)') as SID FROM SCHEDULE
我得到的结果是100010011002
但我想使结果以列或CSV格式.
任何帮助都会被贬低.
使用MS sql Server,这将给你行.
原文链接:https://www.f2er.com/xml/292246.htmldeclare @xml as xml set @xml = '<Configuration> <ID>1000</ID> <ID>1001</ID> <ID>1002</ID> </Configuration>' select x.i.value('.','int') as ID from @xml.nodes('/Configuration/ID') as x(i)
如果在这个例子中只需要一个值,那么在text()节点上更快(三次)).
select x.i.value('.','int') as ID from @xml.nodes('/Configuration/ID/text()') as x(i)