SELECT ... FOR XML

  • Silly question, but how can I store the XML returned from a SELECT FOR XML statement?

    Basically, I want to create XML from a select statement, then store the XML into a variable. I can see the XML returned (usually truncated!) in rows in the query analyser, but is it possible to store this to a variable, ideally a table variable??

    Thanks.

  • In 2005 you can use the XML datatype, in 2000 you can use varchar(8000) if your xml is not greater than 8000 otherwise the text datatype can hold you xml... 

    -

  • Thanks for your reply, but that hasn't really answered my question .... how do I get the XML results from the SELECT into the variable??

  • http://www.sqlxml.org/

    This site has a lot of info on xml and SQL, one of the FAQ is how to get XML from SQL and gives an example using openquery...

     

    -

  • Thanks Jason, looks like a good place for info!!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply