SQL data to XML
- From: "HSalim[MVP]" <HSalim@xxxxxxx>
- Date: Sun, 9 Jul 2006 12:56:45 -0400
Hi,
I am helping a customer move data into NetSuite.
My knowledge of XML is sketchy; it has improved from almost nothing since I
started on this project.
I have a query ready to extract data, which I have rewritten using sample
data from the adventureworks database.
(pated below)
How do I save the output of this query to a file?
How do I add a reference to the DTD?
<!DOCTYPE smbxml SYSTEM "http://www.netsuite.com/xml/dtd/smb_5_01.dtd">
What I'm doing for now is that I run the query in SQL MAnagement Studio,
manually paste the xml header and DTD lines and save it to a file. Surely
there must be a few ways that are better?
Ideally, I'd like to use VBScript - I'd have a shortcut that I would
execute, vbscript prompts for output filename and that's that
(I'll be using integrated security)
I started reading about XSL trnsformations and I still havent grasped it
well enough to apply it to what I need to get done.
I know there is the XML DOM, but I know nothing about it either. Should I
look more into the XML DOM?
Any advice, sample code and pointers to resources would be helpful. Thanks
in advnace for the assistance.
Regards
Habib
------------sample query ------------------------
select (
select rtrim(C.CustomerID) as [@handle]
,(select
(select
CustomerID as [@handle]
, TerritoryID as [territory]
, AccountNumber as [accountNumber]
, CustomerType as [customerType]
, rowguid as [rowGuid]
, convert( char(10),ModifiedDate, 101) as [modifiedDate]
, (Select AddressID as [addressRef/name]
, AddressTypeID as [addressType/name]
, convert( char(10),ModifiedDate, 101) as [modifiedDate]
from sales.customerAddress
where CustomerID = C.CustomerID
for XML PATH('AddressLine'), TYPE ) as [AddressList]
for XML PATH ('customer'), type)
for XML PATH ('addOrUpdate'), type)
from sales.Customer C
where customerID < 5
for XML PATH ('request'), type)
for XML PATH ('smbXML'), type
.
- Follow-Ups:
- Re: SQL data to XML
- From: Michael Rys [MSFT]
- Re: SQL data to XML
- Prev by Date: Re: Recommendations - XML or traditional relational structure
- Next by Date: Re: Sql Server 2005 Xml Dml using .modify()
- Previous by thread: Re: Recommendations - XML or traditional relational structure
- Next by thread: Re: SQL data to XML
- Index(es):
Relevant Pages
|
Loading