Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Running the below 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.
like image 974
JohnLBevan Avatar asked Jan 09 '15 16:01

JohnLBevan


1 Answers

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

The issue was the / on the end of the xpath. i.e.

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

Should have been:

from @xml.nodes('/*/Event') [Events]([Event])
like image 105
JohnLBevan Avatar answered Nov 15 '22 20:11

JohnLBevan