I have used this code. Can anyone help me on the code part to move the data one database to another?
SqlConnection SourceServerName = new SqlConnection(@"Data Source = Stack; Initial Catalog = SSIS2;Trusted_Connection=yes;");
SqlConnection DestinationServerName = new SqlConnection(@"Data Source = Stack; Initial Catalog = SSIS1;Trusted_Connection=yes;");
SqlCommand Cmd = new SqlCommand("SELECT NAME FROM sys.TABLES", SourceServerName);
SourceServerName.Open();
System.Data.SqlClient.SqlDataReader reader = Cmd.ExecuteReader();
while(reader.Read())
{
Cmd = new SqlCommand("TRUNCATE TABLE " + reader["name"], DestinationServerName);
DestinationServerName.Open();
Cmd.ExecuteNonQuery();
reader = Cmd.ExecuteReader();
SqlBulkCopy bulkData = new SqlBulkCopy(DestinationServerName);
// String Dest = reader["name"].ToString();
bulkData.DestinationTableName = reader["name"].ToString();
bulkData.WriteToServer(reader);//reader);
bulkData.Close();
DestinationServerName.Close();
}
SourceServerName.Close();