dbTalk Databases Forums  

work with xml file

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss work with xml file in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Anja
 
Posts: n/a

Default work with xml file - 07-30-2008 , 09:58 AM






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


Reply With Quote
  #2  
Old   
Gerald Aichholzer
 
Posts: n/a

Default Re: work with xml file - 07-30-2008 , 10:32 AM






Hi,

Anja wrote:
Quote:
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



Reply With Quote
  #3  
Old   
Gerald Aichholzer
 
Posts: n/a

Default Re: work with xml file - 07-30-2008 , 10:32 AM



Hi,

Anja wrote:
Quote:
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



Reply With Quote
  #4  
Old   
Gerald Aichholzer
 
Posts: n/a

Default Re: work with xml file - 07-30-2008 , 10:32 AM



Hi,

Anja wrote:
Quote:
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



Reply With Quote
  #5  
Old   
Gerald Aichholzer
 
Posts: n/a

Default Re: work with xml file - 07-30-2008 , 10:32 AM



Hi,

Anja wrote:
Quote:
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



Reply With Quote
  #6  
Old   
Gerald Aichholzer
 
Posts: n/a

Default Re: work with xml file - 07-30-2008 , 10:32 AM



Hi,

Anja wrote:
Quote:
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



Reply With Quote
  #7  
Old   
Gerald Aichholzer
 
Posts: n/a

Default Re: work with xml file - 07-30-2008 , 10:32 AM



Hi,

Anja wrote:
Quote:
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



Reply With Quote
  #8  
Old   
Gerald Aichholzer
 
Posts: n/a

Default Re: work with xml file - 07-30-2008 , 10:32 AM



Hi,

Anja wrote:
Quote:
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



Reply With Quote
  #9  
Old   
Gerald Aichholzer
 
Posts: n/a

Default Re: work with xml file - 07-30-2008 , 10:32 AM



Hi,

Anja wrote:
Quote:
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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.