Thursday, March 22, 2012

Error in X-Path Query

I am new to XML in SQL Server and X-Path Query

Recently I have done the following virtual lab in techNet site

SQL Server 2005 XML Capabilities

The following query is worked fine in the lab

SELECT TOP 10 Demographics.query('declare default element namespace=

"http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey"

/IndividualSurvey/YearlyIncome')

FROM Sales.Individual

But later I installed SQL Server Express in my system and also the Express Manager CTP

but i am getting the following error if I execute the above query in my system

Msg 9317, Level 16, State 1, Line 1

XQuery [Sales.Individual.Demographics.query()]: Syntax error near '=', expected string literal.

The correct syntax for the XQuery expression is below:

SELECT TOP 10 Demographics.query('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/IndividualSurvey";
/IndividualSurvey/YearlyIncome')
FROM Sales.Individual

sql

No comments:

Post a Comment