I want to exchange the Value of a column in two different rows in Microsoft SQL server

Posted by Silmaril89 on Stack Overflow See other posts from Stack Overflow or by Silmaril89
Published on 2010-04-30T19:28:17Z Indexed on 2010/04/30 19:37 UTC
Read the original article Hit count: 157

Filed under:
|

Hi,

I want to do the following two SQL Queries in Microsoft SQL SERVER

UPDATE Partnerships SET sortOrder = 2 WHERE sortOrder = 1;
UPDATE Partnerships SET sortOrder = 1 WHERE sortOrder = 2;

The only problem is, I don't allow for sortOrder to contain the same value, it is a unique key. How could I get around this, because the first query violates the unique key rule and terminates? Or will I have to get rid of the unique key rule I have?

Thanks!

© Stack Overflow or respective owner

Related posts about tsql

Related posts about sql-server