INSERT INTO CUSTOMER_t
(CustomerID, CustomerName, CustomerStreet, CustomerCity, CustomerState, CustomerZip, CreditLimit)
VALUES(2000, 'Acme TNT', '5460 Dusty Ln.', 'Wiley', 'UT', '75688', 120);

error:

Msg 2627, Level 14, State 1, Line 3 Violation of PRIMARY KEY constraint 'XPKCUSTOMER_t'. Cannot insert duplicate key in object 'dbo.CUSTOMER_t'. The duplicate key value is (2000). The statement has been terminated.

1

There are 1 best solutions below

0
On

To understand how databases work, you need to remember that tables contain information about real things, in the real world.

In this case you have a table of customers. One of those customers is called Acme TNT, and they have a customer id of 2000.

You can't have two entries in the customers table for Acme TNT with an id of 2000, because you don't have two customers called Acme TNT, but only one.

Anyone working with databases will be very familiar with this type of message. They won't ask themselves how to fix the problem, but will instead look to see why they are trying to add the same thing a second time.