October 9, 2008 at 4:29 pm
I have a simple table that had 2 records accidentally added where every field matches between the 2 records. The problem is deleting the records. Sql server will not let me remove the records.
There are no indexes or keys attached to this table yet.
The error message reads:
The row value(s) updated or deleted either do not make the row unique or they alter multiple rows(2 rows).
How can I remove these 2 records?
October 9, 2008 at 4:52 pm
Give this a try:
SET ROWCOUNT 1
DELETE from #tmp where (add all the columns you need to identify the record you want to delete)
SET ROWCOUNT 0
The rowcount will limit the delete to one of the two rows.
Chad
October 10, 2008 at 12:31 pm
Either remove all of them, then re-insert
The SET ROWCOUNT 1 is a neat idea I didn't think of
I was gonna suggest adding an ID identity field, that way you have a UNIQUE key for each row
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy