Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object.

Violation of PRIMARY KEY constraint ‘PK__employee__65D712170519C6AF’. Cannot insert duplicate key in object

INTERVIEW PREPARATION IN 30 MINs – Read Following wires for a quick interview preparation.

  1. SQL Server DBA “Interview Questions And Answers”
  2. SQL Azure Interview Questions and Answers Part – 1
  3. SQL Azure Interview Questions and Answers Part – 2
  4. Powershell Interview Questions and Answers

‘dbo.employeedetails’.

REPRO The Error:

CREATE TABLE employeedetails
(empid INT
,empname VARCHAR(100) PRIMARY KEY
,deptid INT)

INSERT INTO employeedetails VALUES(101,’Tuitionaffordable’,1)
INSERT INTO employeedetails VALUES(102,’Tuitionaffordable’,1)
INSERT INTO employeedetails VALUES(103,’Tuitionaffordable’,1)

Resolution: Primary key doesn’t allow duplicate key. Tuitionaffordable is being inserted more than once.

Regards,
Online MSSQL Classes @ http://tuitionaffordable.webstarts.com

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s