Re: Violation of primary key
From: Dan Guzman (guzmanda_at_nospam-online.sbcglobal.net)
Date: 10/30/04
- Next message: Adam Machanic: "Re: Lost all my stored procedures in MDF file"
- Previous message: Kalen Delaney: "Re: Violation of primary key"
- In reply to: kitty: "Re: Violation of primary key"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 30 Oct 2004 17:41:42 -0500
Like Kalen said, you won't find any existing dups because this is what a
primary key prevents. You can prove this with a query like:
SELECT MyPK
FROM MyTable
GROUP BY MyPK
HAVING COUNT(*) > 1
The error is due to the *new* data you are attempting to insert. Check the
primary key values of the data you are trying to insert and either skip the
rows that already exist or delete those from the table before inserting.
-- Hope this helps. Dan Guzman SQL Server MVP "kitty" <kitty@discussions.microsoft.com> wrote in message news:7649F34D-6B76-4117-AFAC-482A01D1620C@microsoft.com... > Well, it seems that what I ended up doing was entering records manually > directly into the database. I was testing a new field that I created and I > guess I got carried away. Those new records that I was playing with, I > seem > to have deleted but I cannot find the one that is trunkating my database. > Do > you know of a way to find a hanging record with a duplicate primary key? > I > tried sorting by primary key but I dont' see any doops. I ran an access > query where I called it to count doops from my primary key but again, no > doops. Do you know a way in wich we can arrange the records enterd last? > > Thanks > > "Dan Guzman" wrote: > >> I can't think of an accidental server or database setting change that >> would >> cause this error to suddenly appear. >> >> Did you make any design changes to your 'keycode' table (primary key)? >> If >> not, this is probably a legitimate error due to attempting an insert of >> duplicate data (same primary key) into the table. >> >> -- >> Hope this helps. >> >> Dan Guzman >> SQL Server MVP >> >> "kitty" <kitty@discussions.microsoft.com> wrote in message >> news:861F5472-F042-484F-99F2-553A880CD019@microsoft.com... >> > [Microsoft]]ddbc sql server driver][sql driver] violation of primary >> > key >> > constraint 'aaaaakeycode.pk'. cannot insert duplicate key in object >> > 'keycode'(#2627)[Microsoft]]ddbc sql server driver][sql driver] The >> > statement >> > terminated.(#3621) >> > >> > Please help me, I am a newby and I was looking at the settings in my >> > sql >> > database and when i exited out I must have changed something because I >> > am >> > getting the eror above. I checked the settings but nothing seems >> > different. >> > Please help me. Where should I look first? Second? >> > >> > Thanks >> > >> > Celia >> >> >>
- Next message: Adam Machanic: "Re: Lost all my stored procedures in MDF file"
- Previous message: Kalen Delaney: "Re: Violation of primary key"
- In reply to: kitty: "Re: Violation of primary key"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|