XQuery [nodes ()]: syntax error near '<eof>', expected step expression

Executing the following SQL / XPath query returns the following error:

Query:

;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]) 

Error:

 XQuery [nodes()]: Syntax error near '<eof>', expected a step expression. 
+5
source share
1 answer

From: http://www.experts-exchange.com/Database/MS-SQL-Server/Q_27789732.html

The problem was at / at the end of xpath. i.e.

 from @xml.nodes('/*/Event/') [Events]([Event]) 

Must be:

 from @xml.nodes('/*/Event') [Events]([Event]) 
+12
source

Source: https://habr.com/ru/post/1210746/


All Articles