Friday, February 10, 2012

Can not load file into Database Help!

I tried to load a file (Data.xml) into SQLServer 2000 using Schema.xml file
but when i load the file i check the table and nothing was loaded, and i
don't get any error in error.log file
A
I create a file called load.vbs
set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkload")
objBL.ConnectionString = "provider=SQLOLEDB.1;data
source=localhost;database=miDatabase;uid=sa;pwd=;"
objBL.ErrorLogFile = "C:\error.log"
objBL.Execute "C:\Schema.xml", "C:\Data.xml"
set objBL=Nothing
And schema called Schema.xml
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:element name="Registro" sql:relation="Sufisinterno" >
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Tipo" type="xsd:string" />
<xsd:element name="Identificacion" type="xsd:string" />
<xsd:element name="PrimerApellido" type="xsd:string" />
<xsd:element name="SegundoApellido" type="xsd:string" />
<xsd:element name="Nombre" type="xsd:string" />
<xsd:element name="Genero" type="xsd:string" />
<xsd:element name="PaisNacimiento" type="xsd:string" />
<xsd:element name="tmpFechaNaci" type="xsd:string" />
<xsd:element name="IdentificacionTitular" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
And a file called data.xml
<?xml version="1.0" encoding="utf-8"?><PadronInternoPersonasFisicas
xmlns="http://www.sugef.fi.cr/esquemas/SUGEF-PadronInternoPersonasFisicas.xsd"><Registro><Tipo> 1</Tipo><Identificacion>0031977420010001709</Identificacion><PrimerApellido>FRESNEDA</PrimerApellido><SegundoApellido>MORENO</SegundoApellido><Nombre>HAROLD
AMED</Nombre><Genero>1</Genero><FechaNacimiento>13/09/1978</FechaNacimiento><PaisNacimiento>CO</PaisNacimiento><IdentificacionTitular>003197742001 0001709</IdentificacionTitular></Registro><Registro><Tipo>1</Tipo><Identificacion>003860579</Identificacion><PrimerApellido>GONZALEZ</PrimerApellido><SegundoApellido>NIETO</SegundoApellido><Nombre>MARIA
DEL
CARMEN</Nombre><Genero>2</Genero><FechaNacimiento>15/10/1965</FechaNacimiento><PaisNacimiento>CU</PaisNacimiento><IdentificacionTitular>C386579</IdentificacionTitular></Registro><Registro><Tipo>1</Tipo><Identificacion>013478458</Identificacion><PrimerApellido>FIGUEROA</PrimerApellido><SegundoApellido>VANEGAS</SegundoApellido><Nombre>JOSE
RAUL</Nombre><Genero>1</Genero><FechaNacimiento /><PaisNacimiento
/><IdentificacionTitular>013478458</IdentificacionTitular></Registro><Registro><Tipo>1</Tipo><Identificacion>038041262</Identificacion><PrimerApellido>SALAZAR</PrimerApellido><SegundoApellido
/><Nombre>BLANCA
ESTELLA</Nombre><Genero>2</Genero><FechaNacimiento>26/03/2007</FechaNacimiento><PaisNacimiento>US</PaisNacimiento><IdentificacionTitular>038041262</IdentificacionTitular></Registro><Registro><Tipo>1</Tipo><Identificacion>043851379</Identificacion><PrimerApellido>SOTO</PrimerApellido><SegundoApellido>CALDERON</SegundoApellido><Nombre>MARIO
ALBERTO</Nombre><Genero>1</Genero><FechaNacimiento>22/01/1982</FechaNacimiento><PaisNacimiento>CR</PaisNacimiento><IdentificacionTitular>043851379</IdentificacionTitular></Registro><Registro><Tipo>1</Tipo><Identificacion>046164814</Identificacion><PrimerApellido>CROSSTY</PrimerApellido><SegundoApellido
/><Nombre>KEITH
ANTONIO</Nombre><Genero>1</Genero><FechaNacimiento>18/02/1957</FechaNacimiento><PaisNacimiento
/><IdentificacionTitular>046164814</IdentificacionTitular></Registro><Registro><Tipo>1</Tipo><Identificacion>046214376</Identificacion><PrimerApellido>GONZALEZ</PrimerApellido><SegundoApellido
/><Nombre>ENRIQUE</Nombre><Genero>1</Genero><FechaNacimiento>27/02/1937</FechaNacimiento><PaisNacimiento
/><IdentificacionTitular>046214376</IdentificacionTitular></Registro><Registro><Tipo>1</Tipo><Identificacion>064RE001076001999</Identificacion><PrimerApellido>MONTENEGRO</PrimerApellido><SegundoApellido>SANCHEZ</SegundoApellido><Nombre>LIDIA</Nombre><Genero>2</Genero><FechaNacimiento>28/10/1967</FechaNacimiento><PaisNacimiento
/><IdentificacionTitular>064RE001076001999</IdentificacionTitular></Registro></PadronInternoPersonasFisicas>
Hello junior,
I'm pretty sure its because you've got the namespace in your data XML file.
This means that the parsing needs to understand that namespace.
Not sure how you get it to understand it. I'll try a bit of digging
Simon Sabin
SQL Server MVP
http://sqlblogcasts.com/blogs/simons

> I tried to load a file (Data.xml) into SQLServer 2000 using Schema.xml
> file but when i load the file i check the table and nothing was
> loaded, and i don't get any error in error.log file
> A
> I create a file called load.vbs
> set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkload")
> objBL.ConnectionString = "provider=SQLOLEDB.1;data
> source=localhost;database=miDatabase;uid=sa;pwd=;"
> objBL.ErrorLogFile = "C:\error.log"
> objBL.Execute "C:\Schema.xml", "C:\Data.xml"
> set objBL=Nothing
> And schema called Schema.xml
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
> <xsd:element name="Registro" sql:relation="Sufisinterno" >
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="Tipo" type="xsd:string" />
> <xsd:element name="Identificacion" type="xsd:string" />
> <xsd:element name="PrimerApellido" type="xsd:string" />
> <xsd:element name="SegundoApellido" type="xsd:string" />
> <xsd:element name="Nombre" type="xsd:string" />
> <xsd:element name="Genero" type="xsd:string" />
> <xsd:element name="PaisNacimiento" type="xsd:string" />
> <xsd:element name="tmpFechaNaci" type="xsd:string" />
> <xsd:element name="IdentificacionTitular" type="xsd:string" />
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
> And a file called data.xml
> <?xml version="1.0" encoding="utf-8"?><PadronInternoPersonasFisicas
> xmlns="http://www.sugef.fi.cr/esquemas/SUGEF-PadronInternoPersonasFisi
> cas.xsd"><Registro><Tipo>1</Tipo><Identificacion>0031977420010001709</
> Identificacion><PrimerApellido>FRESNEDA</PrimerApellido><SegundoApelli
> do>MORENO</SegundoApellido><Nombre>HAROLD
> AMED</Nombre><Genero>1</Genero><FechaNacimiento>13/09/1978</FechaNacim
> iento><PaisNacimiento>CO</PaisNacimiento><IdentificacionTitular>003197
> 7420010001709</IdentificacionTitular></Registro><Registro><Tipo>1</Tip
> o><Identificacion>003860579</Identificacion><PrimerApellido>GONZALEZ</
> PrimerApellido><SegundoApellido>NIETO</SegundoApellido><Nombre>MARIA
> DEL
> CARMEN</Nombre><Genero>2</Genero><FechaNacimiento>15/10/1965</FechaNac
> imiento><PaisNacimiento>CU</PaisNacimiento><IdentificacionTitular>C386
> 579</IdentificacionTitular></Registro><Registro><Tipo>1</Tipo><Identif
> icacion>013478458</Identificacion><PrimerApellido>FIGUEROA</PrimerApel
> lido><SegundoApellido>VANEGAS</SegundoApellido><Nombre>JOSE
> RAUL</Nombre><Genero>1</Genero><FechaNacimiento /><PaisNacimiento
> /><IdentificacionTitular>013478458</IdentificacionTitular></Registro><
> Registro><Tipo>1</Tipo><Identificacion>038041262</Identificacion><Prim
> erApellido>SALAZAR</PrimerApellido><SegundoApellido /><Nombre>BLANCA
> ESTELLA</Nombre><Genero>2</Genero><FechaNacimiento>26/03/2007</FechaNa
> cimiento><PaisNacimiento>US</PaisNacimiento><IdentificacionTitular>038
> 041262</IdentificacionTitular></Registro><Registro><Tipo>1</Tipo><Iden
> tificacion>043851379</Identificacion><PrimerApellido>SOTO</PrimerApell
> ido><SegundoApellido>CALDERON</SegundoApellido><Nombre>MARIO
> ALBERTO</Nombre><Genero>1</Genero><FechaNacimiento>22/01/1982</FechaNa
> cimiento><PaisNacimiento>CR</PaisNacimiento><IdentificacionTitular>043
> 851379</IdentificacionTitular></Registro><Registro><Tipo>1</Tipo><Iden
> tificacion>046164814</Identificacion><PrimerApellido>CROSSTY</PrimerAp
> ellido><SegundoApellido /><Nombre>KEITH
> ANTONIO</Nombre><Genero>1</Genero><FechaNacimiento>18/02/1957</FechaNa
> cimiento><PaisNacimiento
> /><IdentificacionTitular>046164814</IdentificacionTitular></Registro><
> Registro><Tipo>1</Tipo><Identificacion>046214376</Identificacion><Prim
> erApellido>GONZALEZ</PrimerApellido><SegundoApellido
> /><Nombre>ENRIQUE</Nombre><Genero>1</Genero><FechaNacimiento>27/02/193
> 7</FechaNacimiento><PaisNacimiento
> /><IdentificacionTitular>046214376</IdentificacionTitular></Registro><
> Registro><Tipo>1</Tipo><Identificacion>064RE001076001999</Identificaci
> on><PrimerApellido>MONTENEGRO</PrimerApellido><SegundoApellido>SANCHEZ
> </SegundoApellido><Nombre>LIDIA</Nombre><Genero>2</Genero><FechaNacimi
> ento>28/10/1967</FechaNacimiento><PaisNacimiento
> /><IdentificacionTitular>064RE001076001999</IdentificacionTitular></Re
> gistro></PadronInternoPersonasFisicas>
>
|||Yes you are right if i delete the namespace
xmlns="http://www.sugef.fi.cr/esquemas/SUGEF-PadronInternoPersonasFisicas.xsd"
i can load the file, but file is about 1 Gb size and i want to avoid open
the file for delete the namespace.
Any help would be very helpful.
Thank you.
"Simon Sabin" wrote:

> Hello junior,
> I'm pretty sure its because you've got the namespace in your data XML file.
> This means that the parsing needs to understand that namespace.
> Not sure how you get it to understand it. I'll try a bit of digging
>
> Simon Sabin
> SQL Server MVP
> http://sqlblogcasts.com/blogs/simons
>
>
>

No comments:

Post a Comment