2

In SSMS 2008 R2 I execute:

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

Then, open table in SSMS (right-clicking the table in Object Explorer) with "Edit top 200 rows" option, select a row, press delete (keyboard button),
click "Yes" to confirm and receive error [ 1 ]

Why cannot I delete or edit a row?

[ 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   
---------------------------

Update:
I thought SSMS is XML-antogonistic, but it is the same with any types

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

1 Answers1

6

This is a limitation of the designer/wizard

Since the rows are identical there is nothing that tells sql server which of those 2 rows to delete, remember it is a program not a human... (this is also a reason to have a PK on a table)

You can however do it from a query window

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

or with older syntax

set rowcount 1

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

set rowcount 0
SQLMenace
  • 132,095
  • 25
  • 206
  • 225
  • 1
    +1 Wow, thanks, this is what for SQL Server specialists receive money keeping others out of business! – Gennady Vanin Геннадий Ванин Dec 08 '10 at 11:13
  • 2
    @vgv8, I'm pretty sure that @SQLMenace gets paid to do things a lot more complicated than this. – HLGEM Dec 08 '10 at 14:26
  • @HLGEM, thanks for your information. Really I was interested to know attitude to this but not plain solution (rather basic). This seems had not surprised anybody as something abnormal but even threoretically explained why it is so. This is not true that SSMS cannot distinguish the rows, the rows are different, the one which is selected and the other(s) which is not... – Gennady Vanin Геннадий Ванин Dec 08 '10 at 14:58