Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Services / DTS / July 2008

Tip: Looking for answers? Try searching our database.

work with xml file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anja - 30 Jul 2008 15:58 GMT
Hi...
I work with xml files, I use a foreach loop for process them.
I want to save the xml data into a table...

I can use this query:

DECLARE @xml XML
SELECT @xml =CONVERT(XML, bulkcolumn, 2)
FROM OPENROWSET(BULK 'c:\temp\TLGBAA00000000FE-FEA8780.xml', SINGLE_NCLOB)
AS x
DECLARE @idoc int
EXEC sp_xml_preparedocument @idoc OUTPUT, @xml
insert into tbl_dati
select ID_TP,ID_TD,ID_CPT,CONVERT(datetime, '20'+SUBSTRING(dati_tmst, 7, 2)
+'-'+SUBSTRING(dati_tmst, 4, 2) +'-'+LEFT(dati_tmst, 2)+  '
'+sUBSTRING(dati_tmst, len(dati_tmst)-4, 2)+':'+RIGHT(dati_tmst,
2)+':00.000',121),DATI_VAL
from OpenXml(@idoc, '/Periferica/Dati')
with (ID_TP NCHAR(10) '../ID_TP', ID_TD NCHAR(10) 'ID_TD',ID_CPT NCHAR(10)
'../ID_CPT', DATI_TMST nvarchar(50) 'DATI_TMST',datI_VAL decimal(18,2)
'DATI_VAL')

That are my questions:
1- how I can pass the file name with a variable???
2- what item I must to use for process this query???
3- is there an another way to insert the xml data into table???

thanks
anja
Gerald Aichholzer - 30 Jul 2008 16:32 GMT
Hi,

> Hi...
> I work with xml files, I use a foreach loop for process them.
> I want to save the xml data into a table...

this is the way I did it in a project quite a while ago:

Inside the foreach loop I have loaded the xml file into a
variable using the xml task (xslt) with an identity trans-
formation and storing the result in a variable.

In the data flow task I have used the xml source with "xml
data from variable" (I can't remember why I haven't chosen
"xml file from variable", but most probably I have made
some additional xslt transformations before) and have also
specified a schema (xsd). The xml source has several out-
puts which you can use for filling your tables.

hth,
Gerald
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.