通过SQL Server Management Studio中的编辑器进行更新时,导致此问题的原因是什么。是否有必要为表的主键?什么是通过Sql数据更新时的原因编辑器是否有必要有表的主键?
简单的表tab1
模式
Accid(int, not null),Bench1 (varchar(50),null),Bench2(varchar(50),null)
Accid Bench1 Bench2
-------------------------------
1 null null
1 null null
2 null null
2 null null
3 null null
4 null null
update tab1 set Bench1='xx' where accid=1
工作正常
(2 row(s) affected)
但同时更新通过编辑给错误
我在看了一些帖子,他们SA
表中包含文本或ntext数据 类型的一个或多个列:如果下列条件为真ID
出现此问题。
这些列中的一个的值包含以下字符: 百分号(%) 下划线(_) 左括号([)
- 表不包含主键。
http://support.microsoft.com/kb/925719
所以这里为什么主键是强制性的?
if YES
then how it allows updating through query?
else if(NO)
what is reason behind this?
你有独特的钥匙控制吗? –
根据我的经验,它不需要主键,但行必须在至少1个字段中唯一。该编辑器一次将更改限制为1行。如果它不能区分1行和下一行,则失败。 –
@ roryap没有。我还包括架构屏幕 –