May 27, 2003 at 5:04 am
try following in QA
use northwind
go
select * from customers where customerid = 'ALFKI' for xml auto, elements
results are :
XML_F52E2B61-18A1-11d1-B105-00805F49916B
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<customers><CustomerID>ALFKI</CustomerID><CompanyName>Alfreds Futterkiste</CompanyName><ContactName>Maria Anders</ContactName><ContactTitle>Sales Representative</ContactTitle><Address>Obere Str. 57</Address><City>Berlin</City><PostalCode>12209</PostalCode><Country>Germany</Country><Phone>030-0074321</Phone><Fax>030-0076545</Fax></customers>
Now I hope someone can help me on this.I have written a dynamic sp that will receive an xml stream similiar to the above and insert into a table, do some processing and then return the xml stream again by doing the select for xml auto, elements.
The problem is that I want to give back only the xml stream to the client and not this horrible header XML_2345345 ------ etc. inclusive.
I know that I can turn off column header in the options in QA but since i am doing this in a sp i don't know how to produce the xml stream without the guid header in the result.
I will appreciate any input on this.
May 27, 2003 at 5:21 am
To start with I don't think there is a way to alias the output column in T-SQL.
But you can decide to code the presentation.
But it depends how you are returning the xml to the client, if you are using ASP you can direct the xml straight into an XML DOM and then present it anyway you like.
There are examples in BOL for this.
If you are going into MS Office, then use VBS to mask the output.
May 29, 2003 at 8:56 am
Create your own psuedo-for-xml command and you can do waht you like with the header.
declare @XML nvarchar(4000)
set @XML=(select '<customers><CustomerId>' + customerId + '</CustomerId><CompanyName>' + CompanyName + '</CompanyName></customers>' from customers where customerid = 'ALFKI' )
print @XML
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply