web
You’re offline. This is a read only version of the page.
close
Skip to main content
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

I have the same question (0)
  • 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?

  • 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

    }

  • Martin Dráb Profile Picture
    236,316 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.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Guy Terry Profile Picture

Guy Terry 2 Moderator

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans