saifullah khan

saifullah khan

  • NA
  • 335
  • 301k

copy data from one table to another in database

Jun 7 2011 1:20 AM
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)