|
alasse130
Starting Member
21 Posts |
Posted - 07/16/2011 : 09:51:38
|
Hi, I'm currently running into a problem with using BULK INSERT. My CSV file looks like
"1", "john, doe", "0"
I'm using a format file 1 SQLCHAR 0 0 "\",\"" 2 ID SQL_Latin1_General_CP1_CI_AS 2 SQLCHAR 0 1 "\",\"" 2 Name SQL_Latin1_General_CP1_CI_AS 2 SQLCHAR 0 2 "\",\"" 2 IsDeleted SQL_Latin1_General_CP1_CI_AS
Here's my bulk insert statement: BULK INSERT FROM <filename> WITH ( firstrow=2,FIELDTERMINATOR=',',datafiletype='widechar', FORMATFILE=<formatfile> )
This works well if my csv don't contain any fields with commas in it. But if there are data as shown above, it gives me an error: String or binary data would be truncated. The statement has been terminated.
Is what I'm doing possible at all? I read from MSDN that data fields can never contain field terminators. But my current implementation is based on this blog (http://lanestechblog.blogspot.com/2008/08/sql-server-bulk-insert-using-format.html) demonstrating exactly how can this be accomplished using format files.
Appreciate your suggestions. |
|