为什么我不能在SSMS中删除(编辑)带xml值的行?

时间:2010-12-08 10:49:22

标签: sql-server tsql sql-server-2008 database-design ssms

在SSMS 2008 R2中,我执行:

create table aaa(col1 xml);
go
insert into aaa (col1)
values('<ccc>ddd</ccc>')
go 2

然后,在SSMS中打开表格(右键单击对象资源管理器中的表格),选择“编辑前200行”选项,选择一行,按删除(键盘按钮),
单击“是”确认并收到错误[1]

为什么我不能删除或编辑一行?

[1]

---------------------------
Microsoft SQL Server Management Studio
---------------------------
No rows were deleted.

A problem occurred attempting to delete row 1.
Error Source: Microsoft.SqlServer.Management.DataTools.
Error Message: The row value(s) updated or deleted either do not make the row unique or they alter multiple rows(2 rows).

Correct the errors and attempt to delete the row again or press ESC to cancel the change(s).
---------------------------
OK   Help   
---------------------------

更新:
我认为SSMS是XML-antogonistic,但它与任何类型相同

create table bbb(col1 int);
go
insert into bbb (col1)
values(33)
go 2

1 个答案:

答案 0 :(得分:6)

这是设计师/向导的限制

由于行是相同的,没有什么能告诉sql server要删除哪两行,记住它是一个不是人类的程序...(这也是在表上有PK的原因)

但您可以从查询窗口

执行此操作
delete top (1)
from aaa
where convert(varchar(max),col1) = '<ccc>ddd</ccc>'

或使用较旧的语法

set rowcount 1

delete 
from aaa
where convert(varchar(max),col1) = '<ccc>ddd</ccc>'

set rowcount 0