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 delete all records from table?

(0) ShareShare
ReportReport
Posted on by

I have a class's method to insert data from one table to another.

NOW

Data should be inserted only when the second table  is empty....if the second table is NOT empty , it should call a method to delete all records from that table and then insert the data. 

plz help

regards

rajesh

*This post is locked for comments

  • Martin Dráb Profile Picture
    233,396 Most Valuable Professional on at
    RE: how to delete all records from table?

    How do you all expect this to work in a multi-user environment? One user will start putting records to the table and another user will start the same process, deleting the data for everybody. This design seems to have significant flaws.

    I would return to the actual business requirement and build a different solution.

  • AX 2012 r3 Profile Picture
    2,426 on at
    RE: how to delete all records from table?

    Table1  table1;

    table2 table2;

    select firstfast table2;  //Check for a record in table2..because 1st record is enough to check data is there or not

    if(!table2)

    {

    //Insert you logic

    }

    else

    {

    // Logic to delete Table 2

       ttsBegin;

       delete_from   table2;

       ttsCommit

    }

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at
    RE: how to delete all records from table?

    Why don't you call a truncate/delete on the table always, then you would have no records in there each time you try to insert?

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans