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
 General SQL Server Forums
 New to SQL Server Programming
 XML load

Author  Topic 

AAAV
Posting Yak Master

152 Posts

Posted - 2010-08-18 : 13:35:51
I have an XML like
<root>
<version>1</version>
<customer>1</customer>
<customer>2</customer>
..
<customer>100</customer>
</root>

I have a schema xsd file. the customer element has many attributes and some may be in one and some may not be in one. but the xsd has the list of the complete structure.
Is there a way for me to bulk load the complete xml(nulls in the missing attributes) into a table in SQL server 2005/2008. If yes what is that?

I am familiar with nodes() and am looking for some other faster method.
Thanks

X002548
Not Just a Number

15586 Posts

Posted - 2010-08-18 : 14:05:00
you need xml in his form


DECLARE @Doc varchar(max)
SET @doc = '<BUSINESS_ENV_CERTIFICATION>'
+'<Cert_Cols CompanyCD="111222333" YearObtained="2014" CertClassification="N" CertDescription="ZZZ cert"></Cert_Cols>'
+'<Cert_Cols CompanyCD="111222333" YearObtained="2015" CertClassification="N" CertDescription="OSHA cert"></Cert_Cols>'
+'<Cert_Cols CompanyCD="111222333" YearObtained="2018" CertClassification="N" CertDescription="WDD cert"></Cert_Cols>'
+'<Cert_Cols CompanyCD="111222333" YearObtained="2016" CertClassification="Y" CertDescription="WLF cert"></Cert_Cols>'
+'<Cert_Cols CompanyCD="111222333" YearObtained="2017" CertClassification="Y" CertDescription="GP cert"></Cert_Cols>'
+'<Cert_Cols CompanyCD="111222333" YearObtained="2019" CertClassification="Y" CertDescription="EDF cert"></Cert_Cols>'
+ '</BUSINESS_ENV_CERTIFICATION>'


EDIT: BUSINESS_ENV_CERTIFICATION being a table, and the others are columns in that table

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2010-08-18 : 14:15:27
using SQL SSIS would be even easier :)
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-08-18 : 14:34:50
quote:
Originally posted by slimt_slimt

using SQL SSIS would be even easier :)


I suggest you delete this post before Brett sees it
Go to Top of Page

AAAV
Posting Yak Master

152 Posts

Posted - 2010-08-18 : 14:39:07
quote:
Originally posted by slimt_slimt

using SQL SSIS would be even easier :)



Please explain
Go to Top of Page
   

- Advertisement -