FOR XML code that appears above query results - XML SOAP

This is a discussion on FOR XML code that appears above query results - XML SOAP ; When I query using FOR XML, query ****yzer always returns some kind of ID code prior to the query results, e.g.: XML_F52E2B61-18A1-11d1-B105-00805F49916B <Schema name="Schema7" xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes"> <ElementType name="Northwind..Employees" content="eltOnly" model="closed" order="many"> <element type="firstname"/> <element type="lastname"/> <element type="employeeid"/> </ElementType> <ElementType name="firstname" ...

+ Reply to Thread
Results 1 to 2 of 2

FOR XML code that appears above query results

  1. Default FOR XML code that appears above query results

    When I query using FOR XML, query ****yzer always returns some kind of ID
    code prior to the query results, e.g.:

    XML_F52E2B61-18A1-11d1-B105-00805F49916B
    <Schema name="Schema7" xmlns="urn:schemas-microsoft-com:xml-data"
    xmlns:dt="urn:schemas-microsoft-com:datatypes">
    <ElementType name="Northwind..Employees" content="eltOnly" model="closed"
    order="many">
    <element type="firstname"/>
    <element type="lastname"/>
    <element type="employeeid"/>
    </ElementType>
    <ElementType name="firstname" content="textOnly" model="closed"
    dt:type="string"/>
    <ElementType name="lastname" content="textOnly" model="closed"
    dt:type="string"/>
    <ElementType name="employeeid" content="textOnly" model="closed"
    dt:type="i4"/>
    </Schema><Northwind..Employees xmlns="x-schema:#Schema7">
    <firstname>Nancy</firstname>
    <lastname>Davolio</lastname>
    <employeeid>1</employeeid>
    </Northwind..Employees>

    Any idea why the code is there?
    Also, when called from an application, does SQL Server return the code to
    the application?

    Thanks.





  2. Default Re: FOR XML code that appears above query results

    Hello Internet,

    > When I query using FOR XML, query ****yzer always returns some kind of
    > ID code prior to the query results, e.g.:


    What you are using is the name the query engine gave the column of output.
    For example:

    using System;
    using System.Data;
    using System.Data.SqlClient;
    namespace forxml {
    class Program {
    static void Main(string[] args) {
    using (SqlConnection conn = new SqlConnection("Data Source=.;Initial
    Catalog=northwind;Integrated Security=True")) {
    conn.Open();
    using (SqlCommand cmd = conn.CreateCommand()) {
    cmd.CommandText = "select top 1 * from dbo.employees
    for xml auto,elements,xmlschema";
    cmd.CommandType = CommandType.Text;
    using (SqlDataAdapter da = new SqlDataAdapter(cmd)) {
    DataTable dt = new DataTable("this");
    da.Fill(dt);
    foreach (DataColumn c in dt.Columns) {
    Console.WriteLine(c.ColumnName);
    }
    }
    }
    }
    Console.ReadLine();
    }
    }
    }

    What it isn't imporantant, its more or less meaningless. If it bothers you,
    consider using this form of the query instead...

    ;with results(col) as (select top 1 * from dbo.employees for xml auto,elements,xmlschema,type)
    select col from results

    Then you can call it what you like.

    Thanks,
    Kent Tegels, DevelopMentor
    http://staff.develop.com/ktegels/



+ Reply to Thread

Similar Threads

  1. Query based on the results of another query?
    By Application Development in forum ADO DAO RDO RDS
    Replies: 5
    Last Post: 12-09-2007, 06:04 PM
  2. Showing Query Results from VBA SQL Query
    By Application Development in forum ADO DAO RDO RDS
    Replies: 0
    Last Post: 09-17-2007, 09:38 AM
  3. Group Query results in VBA
    By Application Development in forum ADO DAO RDO RDS
    Replies: 3
    Last Post: 08-15-2007, 04:54 PM
  4. Index server query returns no results with correctly formed query
    By Application Development in forum Inetserver
    Replies: 0
    Last Post: 10-31-2004, 10:09 PM
  5. Query Results?
    By Application Development in forum Inetserver
    Replies: 1
    Last Post: 01-09-2004, 02:48 PM