title: Using SQL Server "FOR XML": Convert Result Datatype to Text/varchar/string whatever?
body: <p>I'm struggling with this nearly one week now, and still haven't found any solution -.-</p>
  
  <p>My goal is to receive an XML from a SQL Server by querying with the "FOR XML" statement, taking this XML as a string/stream to forward to a XSLT Transformer and presenting the result as HTML.</p>
  
  <p>The poor thing about it is the webserver environment I should use: IBM Domino 8.5.2, which usually uses Lotus Script and Lotus Notes Databases to generate websites.</p>
  
  <p>But now the performance of Notes databases have reached their dead end, when talking about big databases like our website hit statistics which store millions of hits as datasets. So we decided to migrate to an mssql2008 server that can provide custom filtered results more quickly.</p>
  
  <p>I did actually manage to establish a connection to SQL Server, submit a query and have the result as xml. But ... now? :) It seems that SQL Server provides his "for xml"-queried results as a kind of own weird datatype of binary encoded chars that make no sense when printing them or saving to a file. And Lotus Script (pretty much VBScript) doesn't seem to have a possibility to handle this xml datatype.</p>
  
  <p>I tried every way i could find getting the result - Lotus built in ODBC class, LCConnection via OleDB, ADO Connection via OleDB... but every try ends in a bunch of unreadable data.</p>
  
  <p>I could imagine a webservice between domino and SQL Server, preparing the data as string for my domino script, but that's unnecessary overhead i'd like to avoid.</p>
  
  <p>Can you tell in the sql statement what datatype you want the resulting xml to be? just like cast()/convert() for fields but for the whole xml result? So that i could just read the result as text/varchar field?</p>
  
  <p>Thx, Chris</p>