You can't defer constraint checks in SQL Server over multiple statements (unless you DISABLE) so you have to avoid the conflict or do it in one statementupdate regionkey set region= CASE areaid WHEN 101 THEN 'ILLI' ELSE 'MICH' END, locale= CASE areaid WHEN 101 THEN 'CHIC' ELSE 'DETR' ENDwhere areaid IN (101, 102); 或更通常(在交易中是这样)or, more conventionally (in a transaction this one)update regionkey set region='AAAA', locale='BBBB' where areaid = 101;update regionkey set region='MICH', locale='DETR' where areaid = 102;update regionkey set region='ILLI', locale='CHIC' where areaid = 101;为什么不交换键而不交换值?除非Areaid具有某些含义,否则通常可以达到理智的结果 Why not swap keys not values? It usually achieves the sane result unless areaid has some meaningupdate regionkey set areaid = 203 - areaid where areaid IN (101, 102); 这篇关于交换两个数据库行而不违反约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-19 18:11