Showing posts with label bulk. Show all posts
Showing posts with label bulk. Show all posts

Wednesday, March 28, 2012

I don't suppose BULK UPDATE exists?... like BULK INSERT?

I have to update a field within a table of 60 records or so. Each record has a different field value. it's type varchar. i was given an excel file with the field values and was thinking of a bulk update like bulk insert, but i don't recall that it's possible that way.

Is the only way to create a table, bulk insert, then merge the two tables together with UPDATE?

Just wanted to see if there was an easier way to do it, otherwise i'll take the latter route. Thanks!

You'll need to bulk insert into a work table, then do the update.

Unfortunately (or maybe, fortunately ) there's not Bulk Update.

Or, you could do the processing with SSIS....

Friday, March 23, 2012

I can't import XML into SQL with Bulk Load

Hi,
I can′t import a XML file into SQL Server with a XDR mapping schema
specifying relationships.
The Error is:
"Schema: missing mapping foreign-ralation on BoletoConta
Code 80004005
Source: schema mapping "
What is wrong?
***********************************
This is a complete script.
CREATE TABLE Boleto (
IdBoleto int NOT NULL ,
Numero varchar (50) ,
TipoBoletoId varchar (50) ,
) ON PRIMARY
GO
CREATE TABLE dbo.BoletoConta (
ContaId int NULL ,
Referencia varchar (50) ,
Valor varchar (50) ,
)
GO
This is the mapping schema file (XDR).
<?xml version="1.0" ?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schemas-microsoft-com:xml:datatypes"
xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<ElementType name="Id" content="textonly" />
<ElementType name="Numero" content="textonly" />
<ElementType name="TipoBoletoId" content="textonly" />
<ElementType name="Root" sql:is-constant="1">
<element type="Boleto" />
</ElementType>
<ElementType name="Boleto" sql:relation="Boleto">
<element type="Id" sql:field="IdBoleto" />
<element type="Numero" />
<element type="TipoBoletoId" />
<element type="BoletoConta">
<sql:relationship key-relation="Boleto" key="IdBoleto"
foreing-relation="BoletoConta" foreing-key="IdBoleto" />
</element>
</ElementType>
<ElementType name="BoletoConta" sql:relation="BoletoConta">
<AttributeType name="ContaId" />
<AttributeType name="Referencia" />
<AttributeType name="Valor" />
<attribute type="ContaId" sql:field="ContaId" />
<attribute type="Referencia" sql:field="Referencia" />
<attribute type="Valor" sql:field="Valor" />
</ElementType>
</Schema>
This is a listing of the XML document specified.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<Root>
<Boleto Id="369" Numero="0000000000369" TipoBoletoId="5" >
<BoletoConta ContaId="5" Referencia="01/07/1990" Valor="0.08" />
</Boleto>
<Boleto Id="89627" Numero="0000000089627" TipoBoletoId="5" >
<BoletoConta ContaId="14" Referencia="01/11/2001" Valor="40.55" />
<BoletoConta ContaId="15" Referencia="01/11/2001" Valor="203.10" />
<BoletoConta ContaId="41" Referencia="01/11/2001" Valor="4112.37" />
<BoletoConta ContaId="42" Referencia="01/11/2001" Valor="0.59" />
</Boleto>
<Boleto Id="89628" Numero="0000000089628" TipoBoletoId="5" >
<BoletoConta ContaId="14" Referencia="01/12/2001" Valor="219.56" />
<BoletoConta ContaId="15" Referencia="01/12/2001" Valor="202.80" />
<BoletoConta ContaId="41" Referencia="01/12/2001" Valor="3830.85" />
<BoletoConta ContaId="42" Referencia="01/12/2001" Valor="6.20" />
</Boleto>
</Root>
This is a script to import to SQL-SERVER 2000
Set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
objBL.ConnectionString = "provider=SQLOLEDB.1;data
source=(local);database=mydb;uid=sa;pwd=
xxx"
objBL.ErrorLogFile = "c:\inetpub\wwwroot\xml\error.log"
objBL.Transaction=true
objBL.Execute "c:\mapa.xml", "c:\dados.xml"
Set objBL = Nothing
Eduardo MaggiI' sorry.
I have found the problem, the sintax "foreing" was wrong the correct is
"foreign".
Don't consider this message.
Eduardo Maggi
"EduardoMaggi" wrote:

> Hi,
> I can′t import a XML file into SQL Server with a XDR mapping schema
> specifying relationships.
> The Error is:
> "Schema: missing mapping foreign-ralation on BoletoConta
> Code 80004005
> Source: schema mapping "
> What is wrong?
> ***********************************
> This is a complete script.
> CREATE TABLE Boleto (
> IdBoleto int NOT NULL ,
> Numero varchar (50) ,
> TipoBoletoId varchar (50) ,
> ) ON PRIMARY
> GO
> CREATE TABLE dbo.BoletoConta (
> ContaId int NULL ,
> Referencia varchar (50) ,
> Valor varchar (50) ,
> )
> GO
> This is the mapping schema file (XDR).
> <?xml version="1.0" ?>
> <Schema xmlns="urn:schemas-microsoft-com:xml-data"
> xmlns:dt="urn:schemas-microsoft-com:xml:datatypes"
> xmlns:sql="urn:schemas-microsoft-com:xml-sql">
> <ElementType name="Id" content="textonly" />
> <ElementType name="Numero" content="textonly" />
> <ElementType name="TipoBoletoId" content="textonly" />
> <ElementType name="Root" sql:is-constant="1">
> <element type="Boleto" />
> </ElementType>
> <ElementType name="Boleto" sql:relation="Boleto">
> <element type="Id" sql:field="IdBoleto" />
> <element type="Numero" />
> <element type="TipoBoletoId" />
> <element type="BoletoConta">
> <sql:relationship key-relation="Boleto" key="IdBoleto"
> foreing-relation="BoletoConta" foreing-key="IdBoleto" />
> </element>
> </ElementType>
> <ElementType name="BoletoConta" sql:relation="BoletoConta">
> <AttributeType name="ContaId" />
> <AttributeType name="Referencia" />
> <AttributeType name="Valor" />
> <attribute type="ContaId" sql:field="ContaId" />
> <attribute type="Referencia" sql:field="Referencia" />
> <attribute type="Valor" sql:field="Valor" />
> </ElementType>
> </Schema>
>
> This is a listing of the XML document specified.
>
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> <Root>
> <Boleto Id="369" Numero="0000000000369" TipoBoletoId="5" >
> <BoletoConta ContaId="5" Referencia="01/07/1990" Valor="0.08" />
> </Boleto>
> <Boleto Id="89627" Numero="0000000089627" TipoBoletoId="5" >
> <BoletoConta ContaId="14" Referencia="01/11/2001" Valor="40.55" />
> <BoletoConta ContaId="15" Referencia="01/11/2001" Valor="203.10" />
> <BoletoConta ContaId="41" Referencia="01/11/2001" Valor="4112.37" />
> <BoletoConta ContaId="42" Referencia="01/11/2001" Valor="0.59" />
> </Boleto>
> <Boleto Id="89628" Numero="0000000089628" TipoBoletoId="5" >
> <BoletoConta ContaId="14" Referencia="01/12/2001" Valor="219.56" />
> <BoletoConta ContaId="15" Referencia="01/12/2001" Valor="202.80" />
> <BoletoConta ContaId="41" Referencia="01/12/2001" Valor="3830.85" />
> <BoletoConta ContaId="42" Referencia="01/12/2001" Valor="6.20" />
> </Boleto>
> </Root>
> This is a script to import to SQL-SERVER 2000
> Set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
> objBL.ConnectionString = "provider=SQLOLEDB.1;data
> source=(local);database=mydb;uid=sa;pwd=
xxx"
> objBL.ErrorLogFile = "c:\inetpub\wwwroot\xml\error.log"
> objBL.Transaction=true
> objBL.Execute "c:\mapa.xml", "c:\dados.xml"
> Set objBL = Nothing
>
>
>
> --
> Eduardo Maggi

I can't import XML into SQL with Bulk Load

Hi,
I can′t import a XML file into SQL Server with a XDR mapping schema
specifying relationships.
The Error is:
"Schema: missing mapping foreign-ralation on BoletoConta
Code 80004005
Source: schema mapping "
What is wrong?
***********************************
This is a complete script.
CREATE TABLE Boleto (
IdBoleto int NOT NULL ,
Numero varchar (50) ,
TipoBoletoId varchar (50) ,
) ON PRIMARY
GO
CREATE TABLE dbo.BoletoConta (
ContaId int NULL ,
Referencia varchar (50) ,
Valor varchar (50) ,
)
GO
This is the mapping schema file (XDR).
<?xml version="1.0" ?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schemas-microsoft-com:xml:datatypes"
xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<ElementType name="Id" content="textonly" />
<ElementType name="Numero" content="textonly" />
<ElementType name="TipoBoletoId" content="textonly" />
<ElementType name="Root" sql:is-constant="1">
<element type="Boleto" />
</ElementType>
<ElementType name="Boleto" sql:relation="Boleto">
<element type="Id" sql:field="IdBoleto" />
<element type="Numero" />
<element type="TipoBoletoId" />
<element type="BoletoConta">
<sql:relationship key-relation="Boleto" key="IdBoleto"
foreing-relation="BoletoConta" foreing-key="IdBoleto" />
</element>
</ElementType>
<ElementType name="BoletoConta" sql:relation="BoletoConta">
<AttributeType name="ContaId" />
<AttributeType name="Referencia" />
<AttributeType name="Valor" />
<attribute type="ContaId" sql:field="ContaId" />
<attribute type="Referencia" sql:field="Referencia" />
<attribute type="Valor" sql:field="Valor" />
</ElementType>
</Schema>
This is a listing of the XML document specified.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<Root>
<Boleto Id="369" Numero="0000000000369" TipoBoletoId="5" >
<BoletoConta ContaId="5" Referencia="01/07/1990" Valor="0.08" />
</Boleto>
<Boleto Id="89627" Numero="0000000089627" TipoBoletoId="5" >
<BoletoConta ContaId="14" Referencia="01/11/2001" Valor="40.55" />
<BoletoConta ContaId="15" Referencia="01/11/2001" Valor="203.10" />
<BoletoConta ContaId="41" Referencia="01/11/2001" Valor="4112.37" />
<BoletoConta ContaId="42" Referencia="01/11/2001" Valor="0.59" />
</Boleto>
<Boleto Id="89628" Numero="0000000089628" TipoBoletoId="5" >
<BoletoConta ContaId="14" Referencia="01/12/2001" Valor="219.56" />
<BoletoConta ContaId="15" Referencia="01/12/2001" Valor="202.80" />
<BoletoConta ContaId="41" Referencia="01/12/2001" Valor="3830.85" />
<BoletoConta ContaId="42" Referencia="01/12/2001" Valor="6.20" />
</Boleto>
</Root>
This is a script to import to SQL-SERVER 2000
Set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
objBL.ConnectionString = "provider=SQLOLEDB.1;data
source=(local);database=mydb;uid=sa;pwd=xxx"
objBL.ErrorLogFile = "c:\inetpub\wwwroot\xml\error.log"
objBL.Transaction=true
objBL.Execute "c:\mapa.xml", "c:\dados.xml"
Set objBL = Nothing
Eduardo Maggi
I' sorry.
I have found the problem, the sintax "foreing" was wrong the correct is
"foreign".
Don't consider this message.
Eduardo Maggi
"EduardoMaggi" wrote:

> Hi,
> I can′t import a XML file into SQL Server with a XDR mapping schema
> specifying relationships.
> The Error is:
> "Schema: missing mapping foreign-ralation on BoletoConta
> Code 80004005
> Source: schema mapping "
> What is wrong?
> ***********************************
> This is a complete script.
> CREATE TABLE Boleto (
> IdBoleto int NOT NULL ,
> Numero varchar (50) ,
> TipoBoletoId varchar (50) ,
> ) ON PRIMARY
> GO
> CREATE TABLE dbo.BoletoConta (
> ContaId int NULL ,
> Referencia varchar (50) ,
> Valor varchar (50) ,
> )
> GO
> This is the mapping schema file (XDR).
> <?xml version="1.0" ?>
> <Schema xmlns="urn:schemas-microsoft-com:xml-data"
> xmlns:dt="urn:schemas-microsoft-com:xml:datatypes"
> xmlns:sql="urn:schemas-microsoft-com:xml-sql">
> <ElementType name="Id" content="textonly" />
> <ElementType name="Numero" content="textonly" />
> <ElementType name="TipoBoletoId" content="textonly" />
> <ElementType name="Root" sql:is-constant="1">
> <element type="Boleto" />
> </ElementType>
> <ElementType name="Boleto" sql:relation="Boleto">
> <element type="Id" sql:field="IdBoleto" />
> <element type="Numero" />
> <element type="TipoBoletoId" />
> <element type="BoletoConta">
> <sql:relationship key-relation="Boleto" key="IdBoleto"
> foreing-relation="BoletoConta" foreing-key="IdBoleto" />
> </element>
> </ElementType>
> <ElementType name="BoletoConta" sql:relation="BoletoConta">
> <AttributeType name="ContaId" />
> <AttributeType name="Referencia" />
> <AttributeType name="Valor" />
> <attribute type="ContaId" sql:field="ContaId" />
> <attribute type="Referencia" sql:field="Referencia" />
> <attribute type="Valor" sql:field="Valor" />
> </ElementType>
> </Schema>
>
> This is a listing of the XML document specified.
>
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> <Root>
> <Boleto Id="369" Numero="0000000000369" TipoBoletoId="5" >
> <BoletoConta ContaId="5" Referencia="01/07/1990" Valor="0.08" />
> </Boleto>
> <Boleto Id="89627" Numero="0000000089627" TipoBoletoId="5" >
> <BoletoConta ContaId="14" Referencia="01/11/2001" Valor="40.55" />
> <BoletoConta ContaId="15" Referencia="01/11/2001" Valor="203.10" />
> <BoletoConta ContaId="41" Referencia="01/11/2001" Valor="4112.37" />
> <BoletoConta ContaId="42" Referencia="01/11/2001" Valor="0.59" />
> </Boleto>
> <Boleto Id="89628" Numero="0000000089628" TipoBoletoId="5" >
> <BoletoConta ContaId="14" Referencia="01/12/2001" Valor="219.56" />
> <BoletoConta ContaId="15" Referencia="01/12/2001" Valor="202.80" />
> <BoletoConta ContaId="41" Referencia="01/12/2001" Valor="3830.85" />
> <BoletoConta ContaId="42" Referencia="01/12/2001" Valor="6.20" />
> </Boleto>
> </Root>
> This is a script to import to SQL-SERVER 2000
> Set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
> objBL.ConnectionString = "provider=SQLOLEDB.1;data
> source=(local);database=mydb;uid=sa;pwd=xxx"
> objBL.ErrorLogFile = "c:\inetpub\wwwroot\xml\error.log"
> objBL.Transaction=true
> objBL.Execute "c:\mapa.xml", "c:\dados.xml"
> Set objBL = Nothing
>
>
>
> --
> Eduardo Maggi