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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Error

Author  Topic 

saigeetha
Starting Member

1 Post

Posted - 2010-08-06 : 15:23:23
Msg 2627, Level 14, State 1, Line 2
Violation of PRIMARY KEY constraint 'PK__emp__7C8480AE'. Cannot insert duplicate key in object 'dbo.emp'.
The statement has been terminated.
Hi i have created a trigger for emp table.Trigger created successfully ,but while i am inserting the values into the table i got the above error.
Emp table structure is:create table emp(empno int primary key, empname varchar(15),job varchar(15),sal money,hiredate datetime ,deptno int)
Trigger query:To verify whether user inserting salary more than 6000 or not.
Inserted value in to the table:insert emp values(125,'Ravi','clerk',8000,'6/7/2007',10) .

Could anyone help on this issue.
Thanks,
saigeetha

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-06 : 15:30:39
A row with that empno already exists, hence the error.

SELECT * FROM emp WHERE empno = 125

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -