You have no reason to have all the data in memory at once so use a DataReader, not a DataSet. 0) ExecuteReader on the SELECT command 1) Iterate the DataReader's columns to create the INSERT command and its parameters 2) Read from the DataReader 3) Set the INSERT command's parameter values 4) ExecuteNonQuery 5) Repeat from 2 as necessary You should also use a try/catch and a transaction.