简体   繁体   English

如果主键已经存在,如何覆盖插入到Sql Server表中?

[英]How to overwrite on an insert into a Sql Server table if primary key already exists?

I have a table in SQL Server which has a primary key column. 我在SQL Server中有一个具有主键列的表。 If I'm entering a new update into a table, the primary key of which already exists as an entry, should I delete the previous entry prior to insertion, or is there a way to overwrite the existing entry? 如果我要在表中输入新更新,该表的主键已经作为条目存在,是否应该在插入之前删除前一个条目,或者是否有办法覆盖现有条目?

如果您将实体框架与.net一起使用,请进行删除,然后插入,因为这样不会混淆EF的对象标识符(保存在内存中)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM