Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
parrot
Posting Yak Master
132 Posts |
Posted - 2009-12-18 : 18:55:52
|
I forgot to assign primary keys to my table in my SQL2005 database. Subsequently I now have duplicate records. I tried to define primary keys but I get an error saying that it would create duplicate keys. So then I tried to delete the duplicate records which gave me another error. I then tried to change some of the data in the record to remove the duplicity and I get the same error which is shown below:No rows were deleted.A problem occurred attempting to delete row 1.Error Source: Microsoft.VisualStudio.DataTools.Error Message: The row value(s) updated or deleted either do not makethe row unique or they alter multiple rows(3 rows).Correct the errors and attempt to delete the row again or press ESC tocancel the change(s). Can anyone tell me how to get rid of duplicate records in a table that has no primary keys set? My goal is to define primary keys for the table so there will be no more duplicate records. |
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-12-19 : 10:43:33
|
Care to provide some sample data and table structure? |
|
|
parrot
Posting Yak Master
132 Posts |
Posted - 2009-12-19 : 14:17:06
|
Thanks for your reply. The columns for the table are as follows: Category (nchar(15), not null)Subcategory (nchar(15), not null)Year (nchar(4), not null)HistDate (nchar(10), not null)Keycode (nchar(4), not null)Submitter (nvarchar(50), null)Headline (nvarchar(100), null)Text (nvarchar(max), null)Source (nvarchar(50), null)Status (nchar(l), null)Hits (decimal(18,0), null)Below is the list of the columns I want to assign primary keys to:Category Subcategory Year HistDate Keycode Obituaries 3 33 1916 9/25/1916 1 Obituaries 3 33 1916 9/25/1916 1 Obituaries 3 33 1916 9/25/1916 1If I tried to change the Keycode on any record to something other than '1' I get the error described in my first topic. If I try to delete any or all 3 records I get the same error. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|
|