SQL Bulk copy (unicode)

bulk bulkinsert sql sqlbulkcopy

Domanda

Ho un problema con il caricamento di massa nel mio database. Il server genera l'errore "La stringa o i dati binari verrebbero troncati", ma i miei dati sembrano essere ok.

Im utilizzando file di dati UTF-16LE con file di formato XML. Grazie per le tue risposte

Ecco il mio file di formato:

<BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <RECORD>
  <FIELD ID="1" xsi:type="NCharTerm" TERMINATOR=";\0" />
  <FIELD ID="2" xsi:type="NCharTerm" TERMINATOR=";\0" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
  <FIELD ID="3" xsi:type="NCharTerm" TERMINATOR=";\0" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
  <FIELD ID="4" xsi:type="NCharTerm" TERMINATOR=";\0" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
  <FIELD ID="5" xsi:type="NCharTerm" TERMINATOR=";\0" />
  <FIELD ID="6" xsi:type="NCharTerm" TERMINATOR=";\0" />
  <FIELD ID="7" xsi:type="NCharTerm" TERMINATOR=";\0" />
  <FIELD ID="8" xsi:type="NCharTerm" TERMINATOR=";\0" />
  <FIELD ID="9" xsi:type="NCharTerm" TERMINATOR=";\0" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
  <FIELD ID="10" xsi:type="NCharTerm" TERMINATOR=";\0" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
  <FIELD ID="11" xsi:type="NCharTerm" TERMINATOR=";\0" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
  <FIELD ID="12" xsi:type="NCharTerm" TERMINATOR=";\0" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
  <FIELD ID="13" xsi:type="NCharTerm" TERMINATOR=";\0" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
  <FIELD ID="14" xsi:type="NCharTerm" TERMINATOR=";\0" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
  <FIELD ID="15" xsi:type="NCharTerm" TERMINATOR="\n\0" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
 </RECORD>
 <ROW>
  <COLUMN SOURCE="1" NAME="RefundId" xsi:type="SQLINT"/>
  <COLUMN SOURCE="2" NAME="Date" xsi:type="SQLNCHAR"/>
  <COLUMN SOURCE="3" NAME="VariableSymbol" xsi:type="SQLNVARCHAR"/>
  <COLUMN SOURCE="4" NAME="RefundType" xsi:type="SQLNVARCHAR"/>
  <COLUMN SOURCE="5" NAME="TollAmount" xsi:type="SQLNUMERIC" PRECISION="28" SCALE="12"/>
   <COLUMN SOURCE="6" NAME="DepositAmount" xsi:type="SQLNUMERIC" PRECISION="28" SCALE="12"/>
   <COLUMN SOURCE="7" NAME="OperativeAmount" xsi:type="SQLNUMERIC" PRECISION="28" SCALE="12"/>
   <COLUMN SOURCE="8" NAME="OIAmount" xsi:type="SQLNUMERIC" PRECISION="28" SCALE="12"/>
  <COLUMN SOURCE="9" NAME="Currency" xsi:type="SQLNVARCHAR"/>
  <COLUMN SOURCE="10" NAME="Prefix" xsi:type="SQLNVARCHAR"/>
  <COLUMN SOURCE="11" NAME="BankAccountNumber" xsi:type="SQLNVARCHAR"/>
  <COLUMN SOURCE="12" NAME="BankCode" xsi:type="SQLNVARCHAR"/>
  <COLUMN SOURCE="13" NAME="BankIBANCode" xsi:type="SQLNVARCHAR"/>
  <COLUMN SOURCE="14" NAME="BankSwiftCode" xsi:type="SQLNVARCHAR"/>
  <COLUMN SOURCE="15" NAME="BeneficiaryName" xsi:type="SQLNVARCHAR"/>
 </ROW>
</BCPFORMAT>

Ecco il mio file di dati:

301;2008/05/05;444441;CN;50;1550;70;900;CZK;;8888888888;0800;;;
302;2008/05/06;444442;UP;50;1550;70;900;CZK;;8888888888;1234;;;
303;2008/05/07;444443;OP;50;1550;70;900;CZK;;8888888888;;;;
304;2008/05/08;444444;CN;60;1550;70;900;CZK;;;0400;;;
305;2008/05/09;444445;UP;70;1550;70;900;CZK;;1234567891;0800;;;
306;2008/05/10;444446;OP;80;1550;70;900;CZK;;8888888888;0800;;;
307;2008/05/11;444447;CN;90;1550;70;900;CZK;;8888888888;0800;CZ7308000000008888888888;;
308;2008/05/12;444448;UP;100;1550;70;900;CZK;;8888888888;0800;;12345678901;
309;2008/05/13;444449;OP;110;1550;70;900;CZK;;;;12234567890qqqq;COBADEFF;**123456789012345678901234567890qqqq**
310;2008/05/14;444450;CN;120;1550;70;900;CZK;;;;;COBADEFF;Herr Norbert Ramscheid
312;2008/05/16;444452;OP;140;1550;70;900;CZK;;;;RO49AAAA1B31007593840000;RNCBROBU;Mr. Papalescu
313;2008/05/17;444453;CN;150;1550;70;900;CZK;;678907890;;;RNCBROBU;Mojmir Fagaras
314;2008/05/18;444454;UP;160;1550;70;900;CZK;;;;;RNCBROBU;Mr. Without Bank Account
315;2008/05/19;444455;OP;170;1550;70;900;CZK;;;;RO49AAAA1B31007593840000;;NoSWIFT Bill
316;2008/05/20;444456;CN;180;2000;70;900;CZK;;;;RO49AAAA1B31007593840000;RNCBROBU;
317;2008/05/21;444457;UP;190;1550;70;900;CZK;;;;DE89370400440532013000;COBADEFF;

Risposta popolare

Presumo che potrebbe esserci un problema con una tabella di destinazione in cui i dati dovrebbero essere caricati.

Esempio
Ad esempio, quando si caricano dati in una stringa di 10 caratteri nella colonna, ad es. Varchar (6), i dati non possono essere caricati in questa colonna poiché supporta solo 6 caratteri e si otterrebbe l'errore come si ottiene ora - i dati verrebbero troncati.



Autorizzato sotto: CC-BY-SA with attribution
Non affiliato con Stack Overflow
Autorizzato sotto: CC-BY-SA with attribution
Non affiliato con Stack Overflow