• Now the problem is that the values "value1" and "value2" are in the wrong columns. We must interchange these with each other, putting the data in "value1" in the "value2" column and vice versa.

    DECLARE @temp AS varchar(50)

    UPDATE swapdata SET @temp=value2,value2=value1,value1=@temp

    Instead of declaring a temporary column, we can declare a temporary variable, and it is possible to swap the data of two columns. This statement will first take the value of column "value2" in @temp variable and then take the data of " value1" column in "value2" and finally take the value of @temp in "value1". It's so simple and a much less time consuming way of swapping the data values. Now try selecting the rows of the table.

    SELECT * FROM swapdata

    I found another solution as well, without the use of any temporary variable. Just execute the following T-SQL and it will swap the column's data.

    UPDATE swapdata SET value2=value1,value1=value2

    So an entire article based around you finding an obscurely complicated way of doing something simple, then as an afterthought putting in the simple, more obvious solution?

    Or have I missed something?