0
I have the following problem:
I am running a Procedure in Sql Sever that generates an XML through the XML PATH command, however, one of the fields is an array, what I got was this:
This select is inside PROC which is what matters to generate XML:
<font face="Courier New" size="2">
<font color = "blue">SELECT</font> <font color = "maroon">order_priority</font> <font color = "maroon">"@ID"</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_number</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_type</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_priority</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_client_name</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_client_phone</font><font color = "silver">=</font><font color = "#FF0080"><b>Isnull</b></font><font color = "maroon">(</font><font color = "maroon">order_client_phone</font><font color = "silver">,</font> <font color = "red">''</font><font color = "maroon">)</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_client_code</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_client_cpf_cnpj</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_client_address</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_client_address_number</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_client_complement</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_client_district</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_client_city</font><font color = "silver">,</font>
<br/> <font color = "fuchsia"><i>Upper</i></font><font color = "maroon">(</font><font color = "maroon">order_client_state</font><font color = "maroon">)</font> <font color = "maroon">order_client_state</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_client_cep</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_exped_name</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_exped_field</font><font color = "silver">=</font><font color = "#FF0080"><b>Isnull</b></font><font color = "maroon">(</font><font color = "maroon">order_exped_field</font><font color = "silver">,</font> <font color = "red">''</font><font color = "maroon">)</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_exped_date</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_erpwms</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_invoices</font><font color = "silver">,</font>
<br/> <font color = "maroon">order_items</font>
<br/><font color = "blue">FROM</font> <font color = "maroon">#temp</font>
<br/><font color = "blue">WHERE</font> <font color = "maroon">order_priority</font> <font color = "silver"><</font> <font color = "black">999</font>
<br/><font color = "blue">ORDER</font> <font color = "blue">BY</font> <font color = "maroon">order_priority</font>
<br/><font color = "blue">FOR</font> <font color = "maroon">xml</font> <font color = "maroon">path</font><font color = "maroon">(</font><font color = "red">'Order'</font><font color = "maroon">)</font><font color = "silver">,</font> <font color = "maroon">root</font><font color = "maroon">(</font><font color = "red">'Customers'</font><font color = "maroon">)</font>
</font>
The result is:
But what I need is, where is the field order_invoices XML would look like this:
Could someone help me with some tips and suggestions on how to achieve this result? Thanks in advance!
Your answer satisfies my question, previously had managed using this query:
– A.Duarte
In case the invoice_ERPWMS field there is more result, the other lines are repeating because of this, you would know a way for me to group to only invoice_ERPWMS if repeat the other lines no?
– A.Duarte
I’ve solved my question!
– A.Duarte