Skip to content
Advertisement

Swap values for two rows in the same table in SQL Server

I want to swap the values from two rows in a table. I have the rows IDs of the two rows. Is there any query to do that? Here is an example. Before the query I have this:

row1 : 1,2,3
row2 : 5,6,7

After the swap I want this:

row1 : 5,6,7
row2 : 1,2,3

Advertisement

Answer

If you want to swap values from one row to the other for two known IDs try something like this:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement