How to get XML from SQL Server

From: R. Daneel Olivaw (nomail)
Date: 03/29/04


Date: Mon, 29 Mar 2004 16:29:45 +0200

Hi all
I have this simple query:
SELECT field0, ..., fieldN FROM mytable where [...] FOR XML AUTO
I use a TAdoQuery to get back result, and I get only a field with a blob
field that holds the XML.

Now I want to read the contents of the blob field, and I use
something like that
  fileStream := TFileStream.Create('c:\tmp\test.xml', fmOpenReadWrite);
  adoStream := TAdoBlobStream.Create(tableview.Fields[0] as TBlobField,
bmRead);
  fileStream.CopyFrom(adoStream, 0);
  fileStream.Free;
  adoStream.Free;
The code works but in the test.xml file I see a lot of strange characters :

This is how appears in the Microsoft Query Analyzer
<clusters clusterid="60689" reelid="0120040331"><spots ...

This is how appears in the test.xml file
D
c l u s t e r _ i d Dr e e l _ i d Ds p o t _ p o

Any Idea ?



Relevant Pages

  • Creating correct XML output?
    ... I'm running a SELECT query (consisting of UNIONS) with FOR XML AUTO ... I cannot get away from running the query as a string since it is built ...
    (microsoft.public.sqlserver.xml)
  • Another problem w/ NULL values in XML
    ... We want to convert NULL columns returned in a query to value of 0 when using ... it w/ FOR XML AUTO. ... XML document. ... WTF?? ...
    (microsoft.public.sqlserver.programming)
  • Re: BLOB data field in INSERT statement
    ... And do not use quotes for column name in your query. ... Vassiliev V. V. ... http://www.oledbdirect.com - The fastest way to access MS SQL Server, ... > How do I format the SQL INSERT statement about the BLOB field: ...
    (borland.public.delphi.database.ado)
  • Re: Query problem ...
    ... The problem is that i have many joins on this query, ... It's a mess because I cannot figure out how to predict how the XML AUTO will ... because I'm using BizTalk 2004 I cannot ... Or would that remove duplicates that you want to have ...
    (microsoft.public.sqlserver.xml)
  • WriteXML encoding strings ! Please help
    ... I fill a dataset in asp.net with a 'FOR XML AUTO' query and Output it ... back to the browser. ... means that the script that I am using can't recognise the first node. ...
    (microsoft.public.dotnet.xml)