Sunday, February 26, 2012

FOR XML

Hello
I'm performing a query against a db with "for xml auto, elements" clause
Something like
Table
Field 0 Setas Primary Key
Field 1
Field 2
SELECT field1, field2 FROM table FOR XML AUTO,ELEMENTS
If I run the query into Query Analyzer I get the result I aspect
<table>
<field1>value</field1>
<field2>value</field2>
<table>
<table>
<field1>value</field1>
<field2>value</field2>
<table>
but if I run the same query from a .vbs script (using wscript to launch it)
I get the following
<table>
<field0>value</field0>
<field1>value</field1>
<field2>value</field2>
<table>
<table>
<field0>value</field0>
<field1>value</field1>
<field2>value</field2>
<table>
The primary key is automatically inserted in the xml
Does somebody know the reason? how to workaround it? or to control it?
ThanksPerhaps your process needs to more specifically map the elements:
http://www.eggheadcafe.com/articles/20030804.asp
2005 Microsoft MVP C#
Robbe Morris
http://www.robbemorris.com
http://www.masterado.net/home/listings.aspx
"Denis" <dzoddi@.mvmnet.com> wrote in message
news:%23%23A2vhuKFHA.4092@.tk2msftngp13.phx.gbl...
> Hello
> I'm performing a query against a db with "for xml auto, elements" clause
> Something like
> Table
> Field 0 Setas Primary Key
> Field 1
> Field 2
> SELECT field1, field2 FROM table FOR XML AUTO,ELEMENTS
> If I run the query into Query Analyzer I get the result I aspect
> <table>
> <field1>value</field1>
> <field2>value</field2>
> <table>
> <table>
> <field1>value</field1>
> <field2>value</field2>
> <table>
> but if I run the same query from a .vbs script (using wscript to launch
> it) I get the following
> <table>
> <field0>value</field0>
> <field1>value</field1>
> <field2>value</field2>
> <table>
> <table>
> <field0>value</field0>
> <field1>value</field1>
> <field2>value</field2>
> <table>
> The primary key is automatically inserted in the xml
> Does somebody know the reason? how to workaround it? or to control it?
> Thanks
>
>

No comments:

Post a Comment