Guest User

Untitled

a guest
Jun 18th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. using (SqlConnection connSource = new SqlConnection(csSource)) // source db
  2. using (SqlCommand cmd = connSource.CreateCommand())
  3. using (SqlBulkCopy bcp = new SqlBulkCopy(csDest)) { // destination db
  4. bcp.DestinationTableName = "SomeTable"; // destination table
  5. cmd.CommandText = "SELECT * FROM [Foo]"; // source table
  6. cmd.CommandType = CommandType.Text;
  7. connSource.Open();
  8. using(SqlDataReader reader = cmd.ExecuteReader()) {
  9. bcp.WriteToServer(reader);
  10. }
  11. }
Add Comment
Please, Sign In to add comment