I have a database name test.dbo. In the database it have two table named Equipment and backup. I want to move some data in the table Equipment to table backup and delete the data in the table Equipment. So, what is the query to use to do it?
I have use this query but it only move the data to table backup without deleting it in table Equipment. Moreover, if i use the query again , error show that the table name already exits.
protected void Button5_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=5CG50749V3\\SQLEXPRESS;Initial Catalog=test;Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand("select * into test.dbo.[backup] from test.dbo.[Equipment] where (SerialNumber = '" + TextBox2.Text + "' or EquipmentID = '" + TextBox1.Text + "' )", con);
cmd.ExecuteNonQuery();
con.Close();
}