I want to create 900.000 new rows in a database and in each of these rows the entry from the array should be written into the column Products
.
My solution mentioned below works but it takes over an hour. How can this be done faster?
My very slow solution:
for (int i = 1; i <= 900000; i++)
{
string SQL_command = "INSERT INTO Database(Produkte) VALUES(" + ProductArray[i] + ")";
SqlConnection con = new SqlConnection(connString);
con.Open();
SqlCommand cmd = new SqlCommand(SQL_command , con);
cmd.ExecuteNonQuery();
con.Close();
}
I use SQL Server and C#