Updating the Next Rec ID Sequence in Dynamics AX

by | Updated December 29, 2017 | Development, Dynamics AX

Recently I had to create database records outside of Dynamics AX. I used SQL to move some records from ISV tables to new standard tables within AX. There was a ton of data, so it was much faster to insert these records using SQL. Initially, I overlooked one important factor. When I created these records outside of the AX environment, the SystemSequences table was not updated.

The SystemSequences table stores the next RecID by table in the AX environment: https://msdn.microsoft.com/en-us/library/systemsequences.aspx
If this table is not updated properly, the users will see duplicate record errors that may not make sense to you. The users had sent me this error below. When I looked at the data, the Load ID did not exist. It didn’t throw an error about Rec IDs, so it’s a bit misleading.


The issue was that I had created records in the WHSLoadTable outside of AX.  The SystemSequences table wasn’t updated, so the next value of the Rec ID was incorrect and throwing an error. In this situation, you must update the SystemSequences table. You’ll need to find the max value for the table and update to the max value + 1.

Here is a portion of the SQL used to fix this issue:

I hope this helps you out!

Related Posts


  1. Peter Petrillo

    Presume that 400 records need to be inserted to a table. The process would HAVE TO be inside of a cursor because I would have to update both myTable and SYSTEMSEQUENCES tables one record at a time.

    I dislike cursors. LOL! Is this assessment correct?

  2. Peter Petrillo

    How would you ensure concurrency problems did not occur when inserting records?

  3. Brandon Carmichael

    Hello Peter,

    Actually for your first question, you could insert your 400 records and then after you’ve inserted the records, update the one systemsequences table record that exists for the table you just inserted the records for. You will need to update the nextval to be the appropriate number, but only just the one time.

    In regards to your second question, you are going to want to make sure you are inserting unique records (paying attention to the primary key of the table). On the insert method, Nicole had a recID that ensured all of her records were unique. SQL should be able to handle all of that for you, but it’s safest to ensure you are using the primary index.

    Hope this helps, thank you.

Submit a Comment

Your email address will not be published. Required fields are marked *

Upcoming Events


02jun2:00 pm2:30 pmBusiness Intelligence for Batch Manufacturers

16jun10:00 am10:30 amHow AP automation can speed up month-end close in D365 Finance

17jun11:00 am12:00 pmConfab Live with Stoneridge – Real Time Marketing Strategies for Success

23jun10:00 am10:30 amThe Modern Manufacturer: Cost Accounting in D365

30jun10:00 am10:30 amAP Automation Checklist for a 2022 Rebound

30jun2:00 pm2:30 pmAchieving Success: How Technology Is Helping Nonprofits Thrive


01jul11:00 am12:00 pmConfab Live with Stoneridge – Dataverse Virtual Entities

14jul12:00 pm12:30 pmBeyond Reporting - What Business Intelligence Can Do For Your Agribusiness

15jul11:00 am12:00 pmConfab Live with Stoneridge – Integration Strategies for End User Success

21jul10:00 am10:30 amThe Modern Manufacturer: Manufacturing Software in the Real World

21jul12:00 pm1:00 pmIs it Worth it to Upgrade to Dynamics 365 Finance and Supply Chain Management? - Everything AX Users Need to Consider

About Stoneridge
Stoneridge Software is a unique Microsoft Gold Partner, with emphasis on partner. With specialties in Microsoft Dynamics 365, Microsoft Dynamics AX, Microsoft Dynamics NAV, Microsoft Dynamics GP and Microsoft Dynamics CRM, we focus on attracting the most knowledgeable experts in the field to our team, and prioritize delivering stellar solutions with maximum impact for your business. At Stoneridge, we are deeply committed to your results. Each engagement is met with a dedicated team, ready to provide thorough, tailored, and expert service. Based in Minnesota, we intentionally “step into your shoes,” wherever you are. We focus on what you care about, and develop trusting, long-term relationships with our clients.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!