Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Msg 2627, Level 14, State 1, Line 1
Violation of PRIMARY KEY constraint 'PK_table123_1'. Cannot insert duplicate key in object 'dbo.table123'. The duplicate key value is (12, 23, 57, 2007-2008, 00001010200, 01, MON/MY/ING/9/06, 10/12/2008, 730, 377).
The statement has been terminated.


well if the data is same..

i would like to make no change...

if no matching then insert ....where all fields are null.
Posted
Comments
KALYANI BIBIN 23-Sep-14 2:00am    
R u inserting the values from ASp?
Is it an identity column?
10923679 23-Sep-14 2:08am    
yeah i am using ASP. but for now i am trying with SQL.. if it works with sql. then its fine

 
Share this answer
 
Comments
Oshtri Deka 23-Sep-14 3:12am    
5.
Beter you use if not exist

SQL
IF NOT EXISTS (select 1 from tablename where Id = @id)
BEGIN
    insert into tablename (Id, Name, Address)
    values (@id, @Name, @Address)
END
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900