using xQuery with XML object in SQL 2005

I am trying to use xQuery in SQL 2005 to return the value of the InvoiceFlag field but I get a blank resultset instead of 1231.
can you tell me where the error is?


declare @xmlInputFields xml
set @xmlInputFields = '<Fields count="6">
  <Field name="ApllicationId" /> 
<!--  TemplateType is the prefix of the csv data file 
  <Field name="TemplateType" /> 
  <Field name="LetterId" /> 
  <Field name="UserID" /> 
  <Field name="SystemDate" /> 
  <Field name="InvoiceFlag">1231</Field> 
select  @xmlInputFields.query('
			for $i in /fields/field
			where $i/@name = "InvoiceFlag"
			return ($i/Field)') AS result

Open in new window

LVL 19
Who is Participating?
Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
I believe it is expecting XML in another format. Check out the format in the links below:
frankyteeAuthor Commented:
sorry for the delay. we had to use openxml method as suggested in your links due to problems with xQuery with SQL.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.