Swap unique indexed column values in database

前端 未结 12 973
伪装坚强ぢ
伪装坚强ぢ 2020-12-03 06:36

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

12条回答
  •  执念已碎
    2020-12-03 06:58

    In SQL Server, the MERGE statement can update rows that would normally break a UNIQUE KEY/INDEX. (Just tested this because I was curious.)

    However, you'd have to use a temp table/variable to supply MERGE w/ the necessary rows.

提交回复
热议问题