{{theTime}}

Search This Blog

Total Pageviews

java.sql.SQLException: Violation of PRIMARY KEY constraint 'DEPARTMENT_PK'. Cannot insert duplicate key in object 'dbo.DEPARTMENT_TABLE'. The duplicate key value is (100193).

This exception will be thrown when same Department record is inserting into the table DEPARTMENT_TABLE.

Quick Fix1: (Pseudo code)
                 Try {
                             Update department_table
                 }catch(java.sql.SQLException) {
                        Insert into department_table
                 }

No comments:

Generate Insert Sql from Select Statement

SELECT 'INSERT INTO ReferenceTable (ID, Name) VALUES (' +        CAST(ID AS NVARCHAR) + ', ''' + Name + ''...