Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 260817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:22:47+00:00 2026-05-11T22:22:47+00:00

The problem is during inserting data from staging table during import routine. The system

  • 0

The problem is during inserting data from staging table during import routine.

The system is a legacy one I inherited, and short term while I develop something more suitable I want to patch things to avoid the data transfer failing.

Unfortunately the facility exists via another application to create an entry into table, called CommReceipt. The key is called CR_Key . if this happens then when the auto routine runs to insert, say 1000 rows we need to import from another system (not my system) with CR_Key values already defined, it fails.

The way I see it I have several options, but all suggestions will be appreciated moving forward for the best solution to this issue (both long and short term fixes) .

It is part of the plan to eliminate functionality in the rogue application (but this is a legacy system, written in legacy unfamilar language and might take a bit of effort)

How do I deal with the primary key violation. Can I continue, reporting the violation to deal with after running data insert.

UPDATE: the Primary key CR_Key also happens to be an identity , is there a way to delete rows which should not be there and insert rows using the same ID. I presume….I turn the identity off, then specify unique values in the ‘missing rows’, is that plausible?
I don’t need to auto increment id now, theinsert routine has ID’s

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:22:47+00:00Added an answer on May 11, 2026 at 10:22 pm

    You could use an instead of insert trigger. Inside the trigger, do an Insert into the table, where not exists CommReceipt.CR_Key = inserted.CR_Key.

    Create trigger T_CommReceiptInsteadOfInsert on CommReceipt
    Instead of Insert
    As
    Begin
    
    --Insert duplicate records into another table
    Insert Into CommReceipt_Duplicates(CR_Key, ...)
    Select CR_Key, ...
    From inserted i
    Where exists (select * from CommReceipt c Where c.CR_Key = i.CR_Key)
    
    --Insert non duplicate records
    Insert Into CommReceipt(CR_Key, ...)
    Select CR_Key, ...
    From inserted i
    Where not exists (select * from CommReceipt c Where c.CR_Key = i.CR_Key)
    
    End
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 223k
  • Answers 223k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The W3 specification that talks about these seem to suggest… May 13, 2026 at 12:31 am
  • Editorial Team
    Editorial Team added an answer I tried this in Firefox: <html lang="en"> <head> <title>iframes</title> </head>… May 13, 2026 at 12:31 am
  • Editorial Team
    Editorial Team added an answer The problem with "no results" is still a problem. I… May 13, 2026 at 12:31 am

Related Questions

I'm exporting data programatically from Excel to SQL Server 2005 using SqlBulkCopy. It works
I am fairly new to asp.net and come into a problem whilst using a
I'm looking for a way to continue execution of a transaction despite errors while
In my SQL Server database schema I have a data table with a date

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.