Thursday, March 8, 2012

Changing Result Column Name

How do I change the column name returned in the result set of a For-
Xml-Explicit query?
Currently I get
XML_F52E2B61-18A1-11d1-B10500805F49916B
---
<root><child/>...</root>
I've tried select ( select .....for xml explicit ) AS MyName, but
that doesn't fly with query analyzer.
Cheers,
AedenAre you on SQL 2000 or 2005?
<aeden.jameson@.gmail.com> wrote in message
news:1189889127.677407.265150@.n39g2000hsh.googlegroups.com...
> How do I change the column name returned in the result set of a For-
> Xml-Explicit query?
> Currently I get
> XML_F52E2B61-18A1-11d1-B10500805F49916B
> ---
> <root><child/>...</root>
>
> I've tried select ( select .....for xml explicit ) AS MyName, but
> that doesn't fly with query analyzer.
> Cheers,
> Aeden
>|||SQL 2k
On Sep 15, 5:48 pm, "Mike C#" <x...@.xyz.com> wrote:
> Are you on SQL 2000 or 2005?
> <aeden.jame...@.gmail.com> wrote in message
> news:1189889127.677407.265150@.n39g2000hsh.googlegroups.com...
>
> > How do I change the column name returned in the result set of a For-
> > Xml-Explicit query?
> > Currently I get
> > XML_F52E2B61-18A1-11d1-B10500805F49916B
> > ---
> > <root><child/>...</root>
> > I've tried select ( select .....for xml explicit ) AS MyName, but
> > that doesn't fly with query analyzer.
> > Cheers,
> > Aeden- Hide quoted text -
> - Show quoted text -|||The only thing I can think of in SQL 2K would be to put the result into a
temporary table first and select from that. You could probably do something
with an XML variable in 2005, which is why I asked. FOR XML EXPLICIT is
deprecated in SQL 2005 and 2008. If you're pulling the result client-side,
the column name might not matter since you can usually reference the result
set columns by ordinal number.
<aeden.jameson@.gmail.com> wrote in message
news:1189916977.141263.183740@.n39g2000hsh.googlegroups.com...
> SQL 2k
>
> On Sep 15, 5:48 pm, "Mike C#" <x...@.xyz.com> wrote:
>> Are you on SQL 2000 or 2005?
>> <aeden.jame...@.gmail.com> wrote in message
>> news:1189889127.677407.265150@.n39g2000hsh.googlegroups.com...
>>
>> > How do I change the column name returned in the result set of a For-
>> > Xml-Explicit query?
>> > Currently I get
>> > XML_F52E2B61-18A1-11d1-B10500805F49916B
>> > ---
>> > <root><child/>...</root>
>> > I've tried select ( select .....for xml explicit ) AS MyName, but
>> > that doesn't fly with query analyzer.
>> > Cheers,
>> > Aeden- Hide quoted text -
>> - Show quoted text -
>

No comments:

Post a Comment