Monday, March 12, 2012

Newbie here. Problems on bulk loading.

Hi guys. I am kinda new in XML bulk loading section. Several tutorials had been done by myself and I get some difficulties when having an attribute in my XML. Here are my table, XML and XML schema for bulk loading.

Tables :

CREATE TABLE [dbo].[Game](
[ID] [int] IDENTITY(1,1) NOT NULL,
[code] [int] NOT NULL,
CONSTRAINT [PK_Game] PRIMARY KEY CLUSTERED
(
[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Match](
[ID] [int] NOT NULL,
[date] [datetime] NULL,
[gamecode] [int] NOT NULL,
CONSTRAINT [PK_Match] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[Match] WITH CHECK ADD CONSTRAINT [FK_Match_Game] FOREIGN KEY([gamecode])
REFERENCES [dbo].[Game] ([code])
GO
ALTER TABLE [dbo].[Match] CHECK CONSTRAINT [FK_Match_Game]

XML :

<?xml version='1.0' encoding='utf-8'?>

<ROOT>

<game code="1"/>

<match id = "1001" date="2007/08/01" />

<match id = "1002" date="2007/08/02" />
</game>


<game code="2"/>

<match id = "1003" date="2007/08/03" />

<match id = "1004" date="2007/08/04" />
</game>


<game code="3"/>

<match id = "1005" date="2007/08/05" />

<match id = "1006" date="2007/08/06" />
</game>


</ROOT>

XML Schema :

<xsdTongue Tiedchema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlnsTongue Tiedql="urnTongue Tiedchemas-microsoft-com:mapping-schema">

<xsd:annotation>
<xsd:appinfo>
<sql:relationship name="gameMatch"
parent="Game"
parent-key="code"
child="Deal"
child-key="gamecode" />
</xsd:appinfo>
</xsd:annotation>

<xsd:element name="game" sql:relation="Game" >
<xsd:complexType>
<xsdTongue Tiedequence>
<xsd:element name="Match"
sql:relation="Match"
sql:relationship="gameMatch" >
<xsd:complexType>
<xsd:attribute name="id" type="xsd:integer" /> -- error occurs on this attribute
</xsd:complexType>
</xsd:element>
</xsdTongue Tiedequence>
<xsd:attribute name="date" type="xsdBig Smileate" />
</xsd:complexType>
</xsd:element>

</xsdTongue Tiedchema>

Hope able to get any assistance here. Thx.

My problem solved. Just the element mistake. Smile

No comments:

Post a Comment