August 8, 2007 at 1:46 pm
On insert of few thousand record iam facing a primary key voilation error.
Is there any metord to skip the error and execute the query successfully.
ScheduleActivityLog Table Structue
/**
Index and Constraints
**/
Insert
into ScheduleActivityLog
SELECT
'INVOICE_ID'= ScMaster.INVOICE_ID,
'Comments'='DIALER DUMP',
'ResultCode'=DialerDump.StatusCode,
'AgentId'='DIALER',
'ActivityDate'=dbo.ConvertTimeZone(CONVERT(CHAR(10),DialerDump.CallDate,121) +' ' + CONVERT(CHAR(12),DialerDump.CallDate,114),'EST','IST'),
'FollowUpDate'=dbo.ConvertTimeZone(CONVERT(CHAR(10),DialerDump.CallDate,121) +' ' + CONVERT(CHAR(12),DialerDump.CallDate,114),'EST','IST'),
'LetterCode'=null,
'PaymentAmt'=null,
'PaymentDate'=null
FROM TempDialerDump DialerDump
INNER JOIN ScheduleMaster ScMaster
ON ScMaster.LeadId= DialerDump.LeadId
WHERE ScMaster.INVOICE_ID is not null
ScheduleActivityLog contains lot of duplicate records.
While executing the above code i get the Primary ket constraint error please help me how can i remove primary ket voilation.
August 8, 2007 at 2:02 pm
You can drop the primary key, however this would likely cause a lot more problems. Most of the time primary keys are placed for a good reason (i.e. to uniquely identify a specific record). I think it would be a really, really bad idea to drop the primary key.
August 8, 2007 at 3:09 pm
If they are unique, can you either SELECT DISTINCT or GROUP BY to remove the duplicates? Other options is to place the records in a temp table and only insert the records that do not exist in the other table. Then you can update the old records with the new records.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply