web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to avoid /Reject duplicates while using insert_recordset

(0) ShareShare
ReportReport
Posted on by 8,223

Hi friends , 

I'm using insert_recordset function to copy data from one table to another but the thing is its duplicating 
records. So any Idea how to avoid or Reject Duplicates while copying data ?

thanks & Regards,

Amith Prasanna

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Vilmos Kintera Profile Picture
    46,149 on at

    You have to use unique indexes to avoid record duplication in a table.

    https://msdn.microsoft.com/en-us/library/bb278358.aspx

  • André Arnaud de Calavon Profile Picture
    301,035 Super User 2025 Season 2 on at

    Hi Amith,

    When data from one table needs to be copied to another? Is the target table different in the unique indexes? Or does this function probably inserts records from the source table twice where it needed to be only once using your statements?

  • Douglas Noel Profile Picture
    3,905 on at

    Hi,

    what's about using a not exist join to the destination  table - using a separate table variable for that - within the select condition on your source table with the join condition on the index field?

    Maybe this can avoid the duplicates, which will raise an exception during insert,  because they aren't selected for the insert operation?

    Regards

    Douglas

  • Suggested answer
    A.Prasanna Profile Picture
    8,223 on at

    Hi Andre,

    Actually i created new table and ad new button to get Purchase order details to another table.yeah you correct it's suppose to be copied once but in this case , if I click that button again and again records will copying as per the number of button clicks .that's what i need to stop.In my table there is no indexes created.

    thanks & Regards,

    Amith Prasanna

  • Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at

    If you haven't implemented any logic to skip such records, you shouldn't be surprised that it doesn't happen.

    Using an not exists join, as suggested by Dougles, sounds like a good idea, don't you think? That will filter out records that are already in your table.

    Of course, you have to decide what is considered a duplicate. For example, you can use PurchId and a unique key in your table and join the tables via PurchId.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans