| Author |
Topic |
|
SarahLOR
Starting Member
18 Posts |
Posted - 2010-04-12 : 05:49:28
|
| Hi,I am trying to bulk insert a csv file into a table but it is complaining that 1 of the columns has type mismatch or invalid character for the specified codepage. The column that is it referring to has no data in it, but there is a column which has a character length of > 100 and when I reduce this to < 100, it works.The table that it is inserting into has a length of 300, so it's not that. Is there a limit on the length of charachters in a column in the CSV file to bulk insert?Thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-12 : 06:03:23
|
| try specifying a format file to specify clearly column & row delimiter------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-12 : 06:10:09
|
quote: Originally posted by SarahLOR Hi,but there is a column which has a character length of > 100 and when I reduce this to < 100, it works.The table that it is inserting into has a length of 300
What data type is the destination column?------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee. |
 |
|
|
SarahLOR
Starting Member
18 Posts |
Posted - 2010-04-12 : 06:17:00
|
| The column that appears to be causing the problem is a VARCHAR(300), but the one that SQL Server says is incorrect is VARCHAR(50) |
 |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-12 : 06:22:23
|
quote: Originally posted by SarahLOR The column that appears to be causing the problem is a VARCHAR(300), but the one that SQL Server says is incorrect is VARCHAR(50)
Is there a comma in the input string? It the string raw (ie, NOT delimited with double quotes)? If so, then it might be trying to insert more than 50 characters from the end of column 1 (ie. after the comma, from the VARCHAR(300) column) into the VARCHAR(50) column.------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee. |
 |
|
|
SarahLOR
Starting Member
18 Posts |
Posted - 2010-04-12 : 06:25:40
|
| There is no comma, just a '-'. But I took this out, and it wasn't the problem. It was just when I reduced the length to below 100 that it worked. |
 |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-12 : 06:30:51
|
| Could you post the entire row from the csv file, as well and the table structure you're trying to insert it into?------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee. |
 |
|
|
SarahLOR
Starting Member
18 Posts |
Posted - 2010-04-12 : 06:34:14
|
| I have found the problem, there is a , in and earllier field!Sorry, brain obviously on go slow today.Thanks for your help |
 |
|
|
|