运行以下SQL / XPath查询会返回以下错误:
查询:
;WITH XMLNAMESPACES (
'http://schemas.microsoft.com/win/2004/08/events/event' as ns
, default 'http://schemas.microsoft.com/win/2004/08/events/event'
)
select [Events].[Event].value('(./System/TimeCreated/@SystemTime)[1]','nvarchar(100)') EventTime
from @xml.nodes('/*/Event/') [Events]([Event])
错误:
XQuery [nodes()]: Syntax error near '<eof>', expected a step expression.
答案 0 :(得分:14)
来自:http://www.experts-exchange.com/Database/MS-SQL-Server/Q_27789732.html
问题是xpath末尾的/
。即。
from @xml.nodes('/*/Event/') [Events]([Event])
应该是:
from @xml.nodes('/*/Event') [Events]([Event])