Stand alone Shredding in SQL Server 2005



I've been going around in circles trying to find the simplest way to shred a
large number of documents into a single table using SS 2005. I'm
overwhelmed by the volume of info and methods available. Performance is the
biggest consideration, as the volume is expected to be large in prod, so from
what I've read it will have to be some type of bulk processing.

My first cut:

I created an xsd, but what command do I use to process the xml file and
shred the data into the corresponding columns in the target table? I don't
want to use VB script if I can help it, and would prefer something like bcp
from the command line or bulk insert from T-SQL.

Here is my test table:

CREATE TABLE [dbo].[Employees](
[LastName] [char](10),
[FirstName] [char](10) ,
[EmployeeID] [int] NULL)

and the XSD that I created:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:element name="Employee" sql:relation="Employees" >
<xsd:complexType>
<xsd:sequence>
<xsd:element name="FName"
sql:field="FirstName"
type="xsd:string" />
<xsd:element name="LName"
sql:field="LastName"
type="xsd:string" />
</xsd:sequence>
<xsd:attribute name="EmpID"
sql:field="EmployeeID"
type="xsd:integer" />
</xsd:complexType>
</xsd:element>
</xsd:schema>

And finally, the xml I want to shred:
<Employee>
<FName> Robby </FName>
<LName> Hall </LName>
<EmpID> 123 </EMPID>
</Employee>
<Employee>
<FName> Eddy </FName>
<LName> obbie </LName>
<EmpID> 456 </EMPID>
</Employee>
<Employee>
<FName> Johnny </FName>
<LName> Reb </LName>
<EmpID> 789 </EMPID>
</Employee>

So in my perfect world, I would like to issue a TSQL command like:

Bulk Insert into dbo.Employees using Employee.xsd with input file
c:\employee.xml

and the table would then magically contain:

Last Name first name Emp#
--------------------------------------
Hall Robby 123
Obbie Eddie 456
Reb Johnny 789


Is something similar to this possible? Or is a lot more work required,
such as coding xpath and xquery statements to pull the elements I want from
the XML? I'm looking for performance and ease of maintenance, as I expect
new elements will be added quarterly.

Thanks!!!
.



Relevant Pages

  • RE: Stand alone Shredding in SQL Server 2005
    ... > what I've read it will have to be some type of bulk processing. ... but what command do I use to process the xml file and ... > from the command line or bulk insert from T-SQL. ... the xml I want to shred: ...
    (microsoft.public.sqlserver.xml)
  • [usb-storage] USB-Sticks laufen einfach nicht
    ... usb-storage: Transport: Bulk ... GetMaxLUN command result is -32, ... Bulk data transfer result 0x0 ... usb-storage: scsi cmd done, result=0x0 ...
    (de.comp.os.unix.linux.misc)
  • Re: Open File from Command Button
    ... On the original template there are 4 command buttons each ... Author of Microsoft Outlook 2007 Programming: ... an employee at a remote site navigates to our functional ... mailbox and to the Incident Report folder. ...
    (microsoft.public.outlook.program_forms)
  • Re: Help w/Self-Join Hierarchy Query
    ... > EXPLICIT then I may find the answer in there. ... > Then there is the ever popular employee - manager adjacency. ... > FOR XML SELF ...
    (microsoft.public.sqlserver.programming)
  • Re: Bulk insert
    ... I would check out the Bulk Copy functionality in TSQL. ... able to eliminate the need to transform into XML if you do. ... > EXEC sp_xml_preparedocument @hDoc OUTPUT,@VersionData ... > int, created_by varchar, created_date datetime) XMLVersion ...
    (microsoft.public.dotnet.framework.adonet)