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?

thanks

Frank
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> 
  </Fields>'
 
select  @xmlInputFields.query('
			for $i in /fields/field
			where $i/@name = "InvoiceFlag"
			return ($i/Field)') AS result

Open in new window

LVL 19
frankyteeAsked:
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:

http://www.15seconds.com/Issue/050803.htm
http://msdn.microsoft.com/en-us/library/ms186918.aspx
0
 
frankyteeAuthor Commented:
sorry for the delay. we had to use openxml method as suggested in your links due to problems with xQuery with SQL.
0
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.