updating SQL server through C# vs2010
Posted on 2012-03-27
I have two identical tables.
I use one as a temporary table for importing data to, so it can be manipulated before updating the real table.
I've tried updaing the real table with:
string SQL = "INSERT INTO ActualReadings " +
" (Date,Time,Thing1, thing2, thing3)" +
"SELECT " +
"(Date,Time,Thing1, thing2, thing3)" +
" FROM TempReadings";
//Declare the Command
SqlCommand cmd = new SqlCommand(SQL, conn);
//Make the connection
int NumRows = 0;
NumRows = cmd.ExecuteNonQuery();
but get an error, that I believe is related to the fact both tables have an identity column (ID).
What's the best way around this?