I have a table from which I read using SqlCommand variable, executing ExecuteReader on it an the on the returned SqlDataReader object I am interating to get each row, from where I do operations on the string to perform on insertion in the new DB using also a SqlCommand variable and executing ExecuteNonQuery().
My question is if there is any more elegant/efficient way to do this ? Something like getting all the rows in one command and insert them all at once or anything else that is better than the current flow.
UPDATE One important thing is that the tables are in different databases on different servers.
insert Something select Foo from SomethingElse), in which case it would execute faster if you wrote it up in a proc and just called the proc. But you'd lose a little bit of control over just exactly what you can do with the data. Also depends on how many records you're working with, how fast you actually need it to run, etc.SqlCommandsince they are associated with different connections.tasks--> importyou can choose SQL server/database source and destination. Is c# a means and an end or a requirement?INSERT INTOstatement, onto another server.