code_junkie

How to choose returned column name in a SELECT FOR XML query?

Nov 12th, 2011
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. SELECT col1
  2. FROM table1
  3. WHERE col2 = 'x'
  4. ORDER by col3
  5. FOR XML path('')
  6.  
  7. XML_F52E2B61-18A1-11d1-B105-00805F49916B
  8. ----------------------------------------
  9. <col1>Foo</col1><col1>Bar</col1>
  10.  
  11. select(
  12. SELECT col1
  13. FROM table1
  14. WHERE col2 = 'x'
  15. ORDER by col3
  16. FOR XML path('')
  17. ) as myName
Add Comment
Please, Sign In to add comment