Swap unique indexed column values in database.

Posted by Ramesh Soni on Stack Overflow See other posts from Stack Overflow or by Ramesh Soni
Published on 2008-08-03T09:55:26Z Indexed on 2010/03/19 19:31 UTC
Read the original article Hit count: 298

Filed under:
|

I have a database table and one of the fields (not primary key) is having unique index on it. Now I want to swap values under this column for two rows. How could this be done? Two hack I know are:

  1. Delete both rows and re-insert them
  2. Update rows with some other value and swap and then update to actual value.

But I don't want to go for these as they do not seem to be the appropriate solution to the problem. Could anyone help me out?

© Stack Overflow or respective owner

Related posts about sql

Related posts about database