Swap values for two rows in the same table in SQL Server
        Posted  
        
            by AmRoSH
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by AmRoSH
        
        
        
        Published on 2010-05-03T13:39:11Z
        Indexed on 
            2010/05/03
            20:18 UTC
        
        
        Read the original article
        Hit count: 264
        
sql-server
I have table and I want to swap the values from two rows. 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
I don't want write it in .NET code because I think an SQL query is easier than that.
© Stack Overflow or respective owner