shshva

shshva

  • NA
  • 37
  • 18.4k

read text file to sql server

May 31 2017 11:27 PM

I have this kind of textfile with 100000 rows:

xx xxxx xxx xxxxx xxxxx xxxx xxxxxx xxxxx x xxx xxx xxxxx xxx-xxxx
xx xxxx xxx xxxxx xxxxx xxxx xxxxxx xxxxx x xxx xxx xxxxx xxx-xxxx xx
xx xxxx xxx xxxxx xxxxx xxxx xxxxxx xxxxx x xxx xxx xxxxx xxx-xxxx xxx xxx  xx
  
i have table in sql
date time   receive    sent      message
 xx    xxxx    xxx        xxxxx   xxxxx xxxx xxxxxx xxxxx x xxx xxx xxxxx xxx-xxxx
 
 

I want to save first 4 data each rows into assigned columns the rest values into ONE column.

am stuck at  save remaining data into one column
 
foreach (var item in data)
{
dt.Columns.Add(new DataColumn());
}
i++;
DataRow row = dt.NewRow();
row.ItemArray = data;
dt.Rows.Add(row);
 

Answers (5)