Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 XML import

Author  Topic 

kmslick
Starting Member

6 Posts

Posted - 2012-05-20 : 01:36:57
I have XML files that I need to import but I have not worked with XML much. Can someone help with the best approach/syntax? Also, the XML input files are 3GB in size.

XML format:
<row id="2">
<account_num>41</account_num>
<log_header_id>1999999798</log_header_id>
<sequence_no>1</sequence_no>
<value>/957 ST GEORGE BARBER ROAD/./DAVIDSONVILLE MD</value>
<status>A</status>
<last_maintenance_dt>2012-05-17 11:21:17.123</last_maintenance_dt>
<last_maintenance_userid>rglacken</last_maintenance_userid>
<LOG_DETAIL_lock>0</LOG_DETAIL_lock>
<value_1>./957 ST GEORGE BARBER ROAD/./DAVIDSONVILLE MD 21035</value_1>
<value_2></value_2>
<value_3></value_3>
<value_4></value_4>
<repetition_no>0</repetition_no>
<binary_format></binary_format>
<value_binary></value_binary>
<value_text></value_text>
</row>

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-20 : 11:04:59
by import do you mean storing XML as it is? or do you mean shredding data from XML onto table fields like account_num,sequence_no etc?


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-20 : 11:20:08
if former look at this

http://msdn.microsoft.com/en-us/library/ms191184.aspx

if latter have a look at nodes(),query(),value() functions in books online

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

kmslick
Starting Member

6 Posts

Posted - 2012-05-20 : 23:41:39
quote:
Originally posted by visakh16

if former look at this

http://msdn.microsoft.com/en-us/library/ms191184.aspx

if latter have a look at nodes(),query(),value() functions in books online

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/



I need to shred it and insert into a SQL table as varchar and numeric fields. Thanks for your help.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-21 : 16:41:39
then make use of nodes() and value() functions

WHats table to which you want to insert. show an example and explain what value should populate which column in table.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -