When i inserted data from csv; description column data truncated with length 255.
datatype for description varchar(max), nvarchar(max), text, etc tried.
my code
string CsvConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +filelocation +"; Extended Properties=\"text;HDR=Yes;FMT=Delimited\"";
using (OleDbConnection connection = new OleDbConnection(excelConnectionString))
{
OleDbCommand command = new OleDbCommand("Select * FROM ["+filename+"]", connection);
connection.Open();
using (DbDataReader dr = command.ExecuteReader())
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnectionString))
{
bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping("description", "description"));
bulkCopy.DestinationTableName = "Table1";
bulkCopy.WriteToServer(dr);
}
}
VS2010, C# SQL2008 R2 10.50 Express
Please suggest if there are another methods for inserting data from CSV to SQL Server