Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using (SqlConnection connSource = new SqlConnection(csSource)) // source db
- using (SqlCommand cmd = connSource.CreateCommand())
- using (SqlBulkCopy bcp = new SqlBulkCopy(csDest)) { // destination db
- bcp.DestinationTableName = "SomeTable"; // destination table
- cmd.CommandText = "SELECT * FROM [Foo]"; // source table
- cmd.CommandType = CommandType.Text;
- connSource.Open();
- using(SqlDataReader reader = cmd.ExecuteReader()) {
- bcp.WriteToServer(reader);
- }
- }
Add Comment
Please, Sign In to add comment