I have such question for database developers.
I have a table which has two columns, first one is ID, Second one is Year(2002,2003,2004…it is string). I want to update them by switching the records.
In the beginning it is like this.
ID Year
1 2002
2 2003
3 2004
I want to switch them and make like this.
ID Year
1 2003
2 2002
3 2004
Please pay attention that My Year Column is unique.
So I tried something like this but did not work for me.
SqlCeCommand sss = new SqlCeCommand("Update Year Set Year='" + Year1 + "' Where Year='" + Year2 + "'", MainWindow._Conn);
Consider setting
idto the number of years that are smaller or equal:Live example at SQL Fiddle.