Solved

Cannot add a record to SQL 2005

Posted on 2008-10-29
2
435 Views
Last Modified: 2008-10-29
Try to add a record to a table but encounter error, with the message below.

Violation of PRIMARY KEY constraint 'PKPM00400'. Cannot insert duplicate key in object 'dbo.PM00400'.
The statement has been terminated.

Bascially, I have tried to use the key fields to select a record on the table but no records is retrieved. However, it pop up with the error when I add the records on it.

0
Comment
Question by:AXISHK
2 Comments
 
LVL 50

Accepted Solution

by:
Ryan Chong earned 300 total points
ID: 22838391
is your Primary Key an auto-incremental field? If it's an auto-increment field, you can omit it in your insert sql statements.
0
 
LVL 8

Assisted Solution

by:rpkhare
rpkhare earned 200 total points
ID: 22838478
I suspect you are attempting to insert duplicate primary key value. Check which column you have defined Primary Key and see that unique values are inserted into it.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question