hi all,
I'm using bulk insert to insert records from a data file into a table in SQL Server. Initially, It's working fine. The field delimiter is known as ',' and the row delimiter is '/n'. However, when we tried to run the bulk insert statement,with data file consist of 1 extra column value (not defined in the table), the value is loaded together into the final column. To clearly illustrate it, i have below :
table1 :
col1 varchar(30)
col2 varchar(30)
col3 varchar(30)
Sample Data file :
val11,val12,val13
val21,val22,val23,val24
val31,val32,val33
when i select * from table1, the results shown as :
col1 col2 col3
-----------------------------------
val11 val12 val13 (fine)
val21 val22 val23,val24 (problem!)
val31 val32 val33 (fine)
the col3's value for row2 is wrong. Does anyone know how should i overcome this? Is there any thing that i've missed out besides specifying fielddelimiter and rowdelimeter in BulkInsert? Thanks in advance!
I'm using bulk insert to insert records from a data file into a table in SQL Server. Initially, It's working fine. The field delimiter is known as ',' and the row delimiter is '/n'. However, when we tried to run the bulk insert statement,with data file consist of 1 extra column value (not defined in the table), the value is loaded together into the final column. To clearly illustrate it, i have below :
table1 :
col1 varchar(30)
col2 varchar(30)
col3 varchar(30)
Sample Data file :
val11,val12,val13
val21,val22,val23,val24
val31,val32,val33
when i select * from table1, the results shown as :
col1 col2 col3
-----------------------------------
val11 val12 val13 (fine)
val21 val22 val23,val24 (problem!)
val31 val32 val33 (fine)
the col3's value for row2 is wrong. Does anyone know how should i overcome this? Is there any thing that i've missed out besides specifying fielddelimiter and rowdelimeter in BulkInsert? Thanks in advance!