sql server - "BULK LOAD DATA CONVERSION ERROR for csv file -
i trying import .csv file getting "bulk load data conversion error" last column. file looks like:
"123456","123","001","0.00"
i have tried below rowterminator:
row terminator = "\"\r\n"
nothing working. ideas on causing record have error? thanks
as per given example below, remove quotes in csv , use terminator "\r\n".
always use format xml when doing bulk insert. provides several advantages such validation of data files etc.
the format file maps fields of data file columns of table. can use non-xml or xml format file bulk import data when using bcp command or bulk insert or insert or transact-sql command
considering input file given you, suppose have table given below :
create table mytestformatfiles ( col1 smallint, col2 nvarchar(50), col3 nvarchar(50), col4 nvarchar(50) );
your sample data file follows :
10,field2,field3,field4 15,field2,field3,field4 46,field2,field3,field4 58,field2,field3,field4
sample format xml 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="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="\r\n" max_length="100" collation="sql_latin1_general_cp1_ci_as"/> </record> <row> <column source="1" name="col1" xsi:type="sqlsmallint"/> <column source="2" name="col2" xsi:type="sqlnvarchar"/> <column source="3" name="col3" xsi:type="sqlnvarchar"/> <column source="4" name="col4" xsi:type="sqlnvarchar"/> </row> </bcpformat>
if unfamiliar format files, check xml format files (sql server).
example illustrated here
Comments
Post a Comment