Selecting few columns of a result set as XML

hot_male

New Member
I have a simple \[code\]SELECT\[/code\] statement which selects few columns from a single table:\[code\]SELECT id, name, phone, address FROM tmp_user\[/code\]Is it possible to change this query so that only \[code\]id\[/code\] and \[code\]name\[/code\] are in select and remaining details are in a xml node? I expected output of this select should be\[code\]id name extra data1 Shreedhar <data><phone>...</phone><address>...</address></data>2 John Doe <data><phone>...</phone><address>...</address></data>3 Jane Doe <data><phone>...</phone><address>...</address></data>\[/code\]The last column is of the returned table should be of XML type with required data. I know how the entire result set can be converted to XML using FOR XML. However I am looking only for part of the columns to be converted. Is it possible?
 
Back
Top