无法在具有唯一索引的对象中插入重复键行 [英] Cannot insert duplicate key row in object with unique index

查看:1030
本文介绍了无法在具有唯一索引的对象中插入重复键行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试运行以下查询:

update OAR.oa_AcademicHead
set  personid=15857
where personid=1234

但我遇到错误:

Cannot insert duplicate key row in object 'OAR.oa_AcademicHead' with unique index 'IX_oa_AcademicHead_personid'.
The statement has been terminated.

可以做什么来解决这个问题?

What can be done to fix this??

推荐答案

表中已经存在 personid 15857 。该列上的唯一索引阻止您使用相同的 personid 提交另一个记录(更新实际上是一个删除和插入)。

A row where personid is 15857 already exists in the table. The unique index on that column is preventing you from committing another record with the same personid (an update is really a delete and insert).

您必须在运行查询之前先删除现有的人。*

You'll have to remove the existing person with that id first before running your query.*

*免责声明:实际上你想做什么;请注意其可能导致的问题。

这篇关于无法在具有唯一索引的对象中插入重复键行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆