Hi everyone,
I have read through some excellent responses already dealing with SQL XML output posts, although what I need might not be a) best to do within a stored proc and b) not possible within a stored proc.
My question is this:
I have a simple table; col1, col2, col3, col4 .. for the purpose of an example, they are all just varchar fields.
I am trying to get those columns out as xml in specific formatted way. One post looked very similar to what I needed using the FOR XML PATH statement.. it had:
FOR XML PATH('cell'), ROOT('rows')
although this of course looked partially correct, but I still had the actual fieldnames nested within the tag...
But anyway, what I need is:
<rows>
<cell row='1'>field 1 contents</cell>
<cell row='2'>field 2 contents</cell>
....
</rows>
So because I need to repeat the tag without the actual field name, I am not sure if I can achieve this?? any ideas???
A bonus extra special thank you if I could also do:
<rows totalcount='xxxx' recordsperpage='yyyy'>
So where xxxx=total count of records from the select, and yyyy=the number of records per page, which of course I probably would either have as a variable or param..
Many thanks for any feedback..
EDIT !!!!!!!!!!! OOPS!
Sorry, the format I am looking for is:
<rows>
<row id='1'>
<cell>field 1 contents</cell>
<cell>field 2 contents</cell>
</row>
</rows>
Doh! anyway.. some great ideas thus far.. thanks so much!