3
Answers

copy data from one table to another in database

Ask a question
i want to copy all the data from one table to another in database on button click event. here is the code.

protected void Button1_Click(object sender, EventArgs e)
{
con.Open();
cmd = new SqlCommand(" Insert into Consumer(ConsumerNo,ConsumerName,StreetNo,PhaseName,SectorName,PlotSize,DateofConnection,PropertyType,Diameter,Status) select ConsumerNo,ConsumerName,Street,Phase,Sector,PlotSize,DateofConnection,PropertyType,Dia,Status From Table", con);
cmd.ExecuteNonQuery();

}

it gives me the following error:
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'Table'.

please help me out.

Answers (3)