Hey everyone,
Im trying to create an XML document with specific element order. Here is what I need: -
<invoice_shipment>
-
<internal_id/>
-
<shipping_cost/>
-
<items>
-
<item_code/>
-
</items>
-
<order_number>
-
</invoice_shipment>
-
So I created a SQl query that uses FOR XML EXPLICIT: -
SELECT 1 AS Tag, NULL AS Parent,
-
internal_id AS [invoice_shipment!1!internal_id!element],
-
ship_cost AS [invoice_shipment!1!shipping_cost!element],
-
NULL AS [items!2!order_Id],
-
NULL AS [item!3!item_code!element],
-
order_number AS [order_number!4]
-
FROM [order]
-
-
UNION
-
SELECT 2 AS Tag, 1 AS Parent,
-
internal_id AS [invoice_shipment!1!internal_id!element],
-
ship_cost AS [invoice_shipment!1!shipping_cost!element],
-
items.order_Id AS [items!2!order_Id],
-
NULL AS [item!3!item_code!element],
-
order_number AS [order_number!4]
-
FROM [order] INNER JOIN
-
items ON [order].internal_id = items.order_Id
-
UNION ALL
-
SELECT 3 AS Tag, 2 AS Parent,
-
internal_id AS [invoice_shipment!1!internal_id!element],
-
ship_cost AS [invoice_shipment!1!shipping_cost!element],
-
items.order_Id AS [items!2!order_Id],
-
item.code AS [item!3!item_code!element],
-
order_number AS [order_number!4]
-
FROM [order]
-
INNER JOIN
-
items ON [order].internal_id = items.order_Id INNER JOIN
-
item ON items.items_Id = item.items_Id
-
-
UNION ALL
-
SELECT 4 AS Tag, 1 AS Parent,
-
internal_id AS [invoice_shipment!1!internal_id!element],
-
ship_cost AS [invoice_shipment!1!shipping_cost!element],
-
null AS [items!2!order_Id],
-
null AS [item!3!item_code!element],
-
order_number AS [order_number!4]
-
FROM [order]
-
-
-
ORDER BY [invoice_shipment!1!internal_id!element], [items!2!order_Id], [item!3!item_code!element], [order_number!4] FOR XML EXPLICIT
-
-
And that returns this: -
<invoice_shipment>
-
<internal_id>1445627</internal_id>
-
<shipping_cost>0</shipping_cost>
-
<order_number>10348</order_number>
-
<items order_Id="1445627">
-
<item>
-
<item_code>EGBBDG</item_code>
-
</item>
-
</items>
-
<order_number>10349</order_number>
-
</invoice_shipment>
-
<invoice_shipment>
-
<internal_id>1445628</internal_id>
-
<shipping_cost>2</shipping_cost>
-
<items order_Id="1445628">
-
<item>
-
<item_code>EGOBDG</item_code>
-
</item>
-
</items>
-
<order_number>10349</order_number>
-
</invoice_shipment>
-
<invoice_shipment>
-
<internal_id>1445629</internal_id>
-
<shipping_cost>10</shipping_cost>
-
<items order_Id="1445629">
-
<item>
-
<item_code>EGBBDG</item_code>
-
</item>
-
</items>
-
<order_number>10350</order_number>
-
</invoice_shipment>
-
<invoice_shipment>
-
<internal_id>1445630</internal_id>
-
<shipping_cost>0</shipping_cost>
-
<items order_Id="1445630">
-
<item>
-
<item_code>EGBBDG</item_code>
-
</item>
-
</items>
-
</invoice_shipment>
-
The first <invoice_shipme nt> item has 2 <order_number > and the last has none. Anybody see what Im doing wrong here or maybe know of another way of doing this?
Thanks
Chad
0 1463 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ken Lindner |
last post by:
I have a need to become familiar with SQL Server 2000 for work.
Needless to say I am new to SQL Server any version, but not IT in
general. My employer has provided me with the SQL Server 2000
Personal disk from the SQL Server 2000 Enterprise kit as this is
reported here on the MSDN web site to be the version that is supported
on Windows XP. In fact so many of you kind people confess to having
succeeded in doing it.
I have tried...
|
by: Thue Tuxen Sørensen |
last post by:
Hi everybody !
I´m maintaining a large intranet (approx 10000 concurrent users) running on
one IIS box and one DB box with sqlserver 2000.
Currently there is 2,5 GB Ram, 1 1400 mhz cpu and 2 scsi disks installed on
the db box.
Sqlserver is set to use max 1,4 GB RAM, and the sqlserver does not seem to
be using it all.
|
by: Harris Boyce |
last post by:
Hello,
I'm trying to use the FOR XML EXPLICIT clause with SQL
Server to deserialize data from my database into a
strongly-typed collection object that I will use
throughout my application. I initially tested my design
by building a collection in code and then serializing it
to/from an XML file, which worked fine. However, I have
hit a brick wall trying to restore the data from SQL
Server. I originally had my collection and object
|
by: maltchev |
last post by:
i need to insert data from an xml file into sql server table.
the xml file contains only one record.
how to insert the data? how to map the names of the fields in the xml file
and the table?
thank you in advance.
|
by: Steve Buster |
last post by:
All right, I have read every forum, newsgroup etc about
this issue and no one seems to know how to fix it. I am
getting a "Server Application Unavailable" exception
running my .NET 1.1 application. I use W2K SP4 and have
applied the hot Fix KB824146 and KB824105, both IE fixes.
I don't have VS installed because this is a Quality
Environment. I do have .NET SDK and .NET 1.1 Runtime
installed. I can't change my APSNET user to run as...
| |
by: Daniel Walzenbach |
last post by:
Hi,
I have a web application which sometimes throws an “out of memoryâ€
exception. To get an idea what happens I traced some values using performance
monitor and got the following values (for one day):
\\FFDS24\ASP.NET Applications(_LM_W3SVC_1_Root_ATV2004)\Errors During
Execution: 7
\\FFDS24\ASP.NET Apps v1.1.4322(_LM_W3SVC_1_Root_ATV2004)\Compilations
|
by: Jobs |
last post by:
Download the JAVA , .NET and SQL Server interview with answers
Download the JAVA , .NET and SQL Server interview sheet and rate
yourself. This will help you judge yourself are you really worth of
attending interviews. If you own a company best way to judge if the
candidate is worth of it.
http://www.questpond.com/InterviewRatingSheet.zip
|
by: rbg |
last post by:
I did use query plans to find out more. ( Please see the thread BELOW)
I have a question on this, if someone can help me with that it will be
great.
In my SQL query that selects data from table, I have a where clause
which states :
where PermitID like @WorkType
order by WorkStart DESC
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |