I have a XML column Demographics
with the example data as -
<StoreSurvey xmlns="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey">
<AnnualSales>800000</AnnualSales>
<AnnualRevenue>80000</AnnualRevenue>
<BankName>United Security</BankName>
<BusinessType>BM</BusinessType>
<YearOpened>1996</YearOpened>
<Specialty>Mountain</Specialty>
<SquareFeet>21000</SquareFeet>
<Brands>2</Brands>
<Internet>ISDN</Internet>
<NumberEmployees>13</NumberEmployees>
</StoreSurvey>
I want to get output as <AnnualSales>800000</AnnualSales>
and I am using this query:
select Demographics.query('/StoreSurvey/AnnualSales')
from Sales.Store
but I am getting error -
Msg 2260, Level 16, State 1, Line 1
XQuery [Sales.Store.Demographics.query()]: There is no element named 'StoreSurvey'
I can clearly see that there is a StoreSurvey
element. Please let me know where i am going wrong