SQL Bulk copy (unicode) - sql

i have a problem with bulk load into my database. Server throws error "String or binary data would be truncated", but my data seems to be ok.
Im using UTF-16LE data file with XML format file.
Thanks for your answers
Here's my format file:
<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>
Here's my data file:
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;

I assume there could be a problem with a destination table where the data should be loaded into.
Example
E.g. when you are loading data in string of 10 characters into the column which is e.g. varchar(6) data type, the data could not be loaded into this column as it supports only 6 characters and you would get the error as you are getting now - the data would be truncated.

Related

BCP insert skip one DB column

I am using a BCP with a file format XML to import from a csv into a SQL database.
It works until I add a new column called DATERIF, that I should skip, but I cannot.
With the following templates, instead of skipping the column, the import is also filling that one, leaving the last one (MODELLO) empty,
I tried to add after the 6th column a row like this one, but in that case an error is raised at runtime.
<COLUMN SOURCE="0" NAME="DATERIF" xsi:type="SQLDATETIME" />
here the complete template file
<?xml version="1.0"?>
<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="CharTerm" TERMINATOR=";" MAX_LENGTH="20"
COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="2" xsi:type="CharTerm" TERMINATOR=";" MAX_LENGTH="20"
COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="3" xsi:type="CharTerm" TERMINATOR=";" MAX_LENGTH="20"
COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="4" xsi:type="CharTerm" TERMINATOR=";" MAX_LENGTH="20"
COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="5" xsi:type="CharTerm" TERMINATOR=";" MAX_LENGTH="20"
COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="6" xsi:type="CharTerm" TERMINATOR=";" MAX_LENGTH="20"
COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="7" xsi:type="CharTerm" TERMINATOR=";" MAX_LENGTH="20"
COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="8" xsi:type="CharTerm" TERMINATOR=";" MAX_LENGTH="20"
COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="9" xsi:type="CharTerm" TERMINATOR=";" MAX_LENGTH="20"
COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="10" xsi:type="CharTerm" TERMINATOR=";" MAX_LENGTH="20"
COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="11" xsi:type="CharTerm" TERMINATOR="\r\n" MAX_LENGTH="20"
COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
</RECORD>
<ROW>
<COLUMN SOURCE="1" NAME="HOSTNAME" xsi:type="SQLVARYCHAR" LENGTH="20"/>
<COLUMN SOURCE="2" NAME="IP_MACCH" xsi:type="SQLVARYCHAR" LENGTH="20"/>
<COLUMN SOURCE="3" NAME="LOGIN" xsi:type="SQLVARYCHAR" LENGTH="20"/>
<COLUMN SOURCE="4" NAME="T_TYPE" xsi:type="SQLVARYCHAR" LENGTH="20"/>
<COLUMN SOURCE="5" NAME="DATA_RIL" xsi:type="SQLVARYCHAR" LENGTH="20"/>
<COLUMN SOURCE="6" NAME="ORA_RIL" xsi:type="SQLVARYCHAR" LENGTH="20"/>
<COLUMN SOURCE="0" NAME="DATERIF" xsi:type="SQLDATETIME"/>
<COLUMN SOURCE="7" NAME="CUSTOMER" xsi:type="SQLVARYCHAR" LENGTH="20"/>
<COLUMN SOURCE="8" NAME="NUMORDINE" xsi:type="SQLVARYCHAR" LENGTH="20"/>
<COLUMN SOURCE="9" NAME="OPERATORE" xsi:type="SQLVARYCHAR" LENGTH="20"/>
<COLUMN SOURCE="10" NAME="SERIALNUM" xsi:type="SQLVARYCHAR" LENGTH="20"/>
<COLUMN SOURCE="11" NAME="MODELLO" xsi:type="SQLVARYCHAR" LENGTH="20"/>
</ROW>
</BCPFORMAT>
How can I skip this field an import in the following ones?
Thank you
Andrea
I am assuming that you are using MS SQL Server.
The scenario where a DB table has one or few additional column(s) is resolved by using a view. That view definition needs to exclude not needed columns. After that you can BULK INSERT into a view instead of the DB table.
It is documented in BOL: Using BULK INSERT with a view

SQL BCP Unknown Error while attempting to read format file on Ubuntu

I'm trying to automate some importing jobs to my SQL Server database and have the following XML format file:
<?xml version="1.0"?>
<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="CharFixed" LENGTH="11" COLLATION="SQL_Latin1_General_CP1_CI_AS" />
<FIELD ID="2" xsi:type="CharFixed" LENGTH="30" COLLATION="SQL_Latin1_General_CP1_CI_AS" />
<FIELD ID="3" xsi:type="CharFixed" LENGTH="2" COLLATION="SQL_Latin1_General_CP1_CI_AS" />
<FIELD ID="4" xsi:type="CharFixed" LENGTH="2" COLLATION="SQL_Latin1_General_CP1_CI_AS" />
<FIELD ID="5" xsi:type="CharFixed" LENGTH="2" COLLATION="SQL_Latin1_General_CP1_CI_AS" />
<FIELD ID="6" xsi:type="CharFixed" LENGTH="1" COLLATION="SQL_Latin1_General_CP1_CI_AS" />
<FIELD ID="7" xsi:type="CharFixed" LENGTH="1" COLLATION="SQL_Latin1_General_CP1_CI_AS" />
<FIELD ID="8" xsi:type="CharFixed" LENGTH="2" COLLATION="SQL_Latin1_General_CP1_CI_AS" />
<FIELD ID="9" xsi:type="CharTerm" TERMINATOR="\n"/>
</RECORD>
<ROW>
<COLUMN SOURCE="1" NAME="cuit" xsi:type="SQLNUMERIC" PRECISION="11" />
<COLUMN SOURCE="2" NAME="denominacion" xsi:type="SQLVARYCHAR" LENGTH="30" />
<COLUMN SOURCE="3" NAME="imp_ganancias" xsi:type="SQLVARYCHAR" LENGTH="2" />
<COLUMN SOURCE="4" NAME="imp_iva" xsi:type="SQLVARYCHAR" LENGTH="2" />
<COLUMN SOURCE="5" NAME="monotributo" xsi:type="SQLVARYCHAR" LENGTH="2" />
<COLUMN SOURCE="6" NAME="integra_sociedad" xsi:type="SQLVARYCHAR" LENGTH="1" />
<COLUMN SOURCE="7" NAME="empleador" xsi:type="SQLVARYCHAR" LENGTH="1" />
<COLUMN SOURCE="8" NAME="actividad_monotributo" xsi:type="SQLVARYCHAR" LENGTH="2" />
</ROW>
</BCPFORMAT>
And it works fine on my local machine running windows 10 if I run the bcp command
bcp myDB.dbo.myTable IN File.txt -f File.xml -U x -P x -S myIp
But the problem is that I need to leave this commands running on a remote machine running on Ubuntu and when I do I get the following error
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC Driver 17 for SQL Server]Format File : Unknown error occurred while attempting to read.
And I have no Idea why this is happening, I tried changing permissions on the file and running as root but nothing changes.

Can we set collation name while importing data from a CSV file to SQL Server

The default collation name is "SQL_Latin1_General_CP1_CI_AS" when i create a table and import data using CSV file. I just want to set collation name as "Latin1_General_CI_AS" while importing data. Is there any possible way to configure this while importing data itself.
Use a Format File to Bulk Import Data.
For example Format File:
\<?xml version="1.0"?>
\<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="CharTerm" TERMINATOR="," MAX_LENGTH="7"/>
\<FIELD ID="2" xsi:type="CharTerm" TERMINATOR="," MAX_LENGTH="25" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
\<FIELD ID="3" xsi:type="CharTerm" TERMINATOR="," MAX_LENGTH="30" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
\<FIELD ID="4" xsi:type="CharTerm" TERMINATOR="\r\n" MAX_LENGTH="11"/>
</RECORD>
<ROW>
\<COLUMN SOURCE="1" NAME="PersonID" xsi:type="SQLSMALLINT"/>
\<COLUMN SOURCE="2" NAME="FirstName" xsi:type="SQLVARYCHAR"/>
\<COLUMN SOURCE="3" NAME="LastName" xsi:type="SQLVARYCHAR"/>
\<COLUMN SOURCE="4" NAME="BirthDate" xsi:type="SQLDATE"/>
</ROW>
</BCPFORMAT>
And next, for example bulk insert :
BULK INSERT dbo.myTable
FROM 'D:\BCP\myFile.csv'
WITH (FORMATFILE = 'D:\BCP\myFileFormat.fmt');

BULK INSERT tab-delimited file - With commas in Description

I am trying to import a CSV file With the BULK INSERT Function. I am doing it through SQL because it can be an automated process. The problem I picked up is that the CSV file I get from the client has commas in the Item Description i.e Rosetta 10,5x25x4 - When I try to import it that comma in the description causes a problem: Here is the Script I am running:
BULK INSERT ORDERS_DATA
FROM 'C:\back_orders_2013.csv'
WITH
(
FIRSTROW = 2,
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',
TABLOCK
)
Is there a way to ignore that like in excel where you treat consecutive delimiters as one?
Here is the solution:
<?xml version="1.0"?>
<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="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="2" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="3" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="4" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="5" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="6" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="7" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="8" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="9" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="10" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="11" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="12" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="13" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="14" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="15" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="16" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="17" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="18" xsi:type="CharTerm" TERMINATOR=',' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="19" xsi:type="CharTerm" TERMINATOR='\n' MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
</RECORD>
<ROW>
<COLUMN SOURCE="1" NAME="RKID" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="2" NAME="ORNO" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="3" NAME="PONO" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="4" NAME="ITEM_CODE" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="5" NAME="ITEM_DESCRIPTION" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="6" NAME="ORDER_QTY" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="7" NAME="DELIVER_QTY" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="8" NAME="B_QTY" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="9" NAME="RTS_DATE" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="10" NAME="PRICE" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="11" NAME="PLEV" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="12" NAME="DISCOUNT1" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="13" NAME="DISCOUNT2" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="14" NAME="DISCOUNT3" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="15" NAME="TOTAL" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="16" NAME="CURRENCY" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="17" NAME="ORDER_DATE" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="18" NAME="BKYN" xsi:type="SQLVARYCHAR" />
<COLUMN SOURCE="19" NAME="PENTA_REF" xsi:type="SQLVARYCHAR" />
</ROW>
</BCPFORMAT>
This works 100% and the error I received:
String or binary data would be truncated. The statement has been
terminated
Was because of the length of one of my data fields.

sql bulk insert non-standard characters

I am importing data into a sql table from a csv using an xml format file.
When I perform the import it all works well but some extended characters are showing up incorrectly with things like this '▓' the one in particular is the '²'.
I am assuming it is something to do with the encoding of the file and me not telling the import how to handle it but I'm not 100% sure.
My CSV looks like the following
"2","4567","2","234562","","MAX","","2452","m²",""," ","254352"
and my import file
<?xml version="1.0"?>
<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="CharTerm" TERMINATOR='"' />
<FIELD ID="2" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="3" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="4" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="5" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="6" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="7" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="8" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="9" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="10" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="11" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="12" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="13" xsi:type="CharTerm" TERMINATOR='"\r\n' />
</RECORD>
<ROW>
<COLUMN SOURCE="2" NAME="PARCELID" xsi:type="SQLINT"/>
<COLUMN SOURCE="3" NAME="PROPID" xsi:type="SQLINT"/>
<COLUMN SOURCE="4" NAME="LOT" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="5" NAME="RPLAN" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="6" NAME="SECTION" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="7" NAME="PARISH" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="8" NAME="COUNTY" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="9" NAME="AREA" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="10" NAME="AREATYPE" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="11" NAME="ZONING" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="12" NAME="MAPID" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="13" NAME="LOTPLAN" xsi:type="SQLNVARCHAR"/>
</ROW>
</BCPFORMAT>
I'm importing it using the sql command
BULK INSERT [parcel]
FROM 'c:\test\PARCEL.csv'
WITH (FORMATFILE = 'c:\test\PARCEL.xml', KEEPIDENTITY, FIRSTROW = 2, KEEPNULLS)
and my table structure looks like
[PARCELID] [int] NOT NULL
[PROPID] [int] NULL
[LOT] [nvarchar](255) NULL
[RPLAN] [nvarchar](255) NULL
[SECTION] [nvarchar](255) NULL
[PARISH] [nvarchar](255) NULL
[COUNTY] [nvarchar](255) NULL
[AREA] [nvarchar](50) NULL
[AREATYPE] [nvarchar](255) NULL
[ZONING] [nvarchar](255) NULL
[MAPID] [nvarchar](255) NULL
[LOTPLAN] [nvarchar](255) NULL
I have tried setting the bulk insert datafiletype to both 'widenative' and 'widechar' but to no avail.
Is there something else I'm missing here?
Turns out I needed to set the collation on the column itself like
<FIELD ID="10" xsi:type="CharTerm" TERMINATOR='","' COLLATION="Latin1_General_CI_AS" />