Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Can I drop/delete TempDB Tables that AX has created

(0) ShareShare
ReportReport
Posted on by 5

Hi,

I'm a DBA  working with AX for the first time.

I've noticed that application creates a lot of TempDB tables, and due to a lot of the code it doesn't delete most of the tables it creates (i.e the devs never built cleaning up routines in the code). This is creating a big problem because these tables start to eat into the memory of SQL, and take memory that could be used by the buffer pool (i currently have 300k temp tables and growing).

I spoke to one of the AX devs who advised that if AX needs to use a temp table it will create one, and it won't use a previously created table. So from my understanding it is always creating temp tables when required, does what it needs to do, and finishes, doesn't drop the table, rinse and repeat.

But what i have noticed when looking at queries throughout the day, is that some queries are using temp tables that were created weeks ago.

My main questions are, if i delete one of these tables while it is not in use, and then a query runs that would've used that tempdb table. Will AX create a new table because it can't find the previous one, or would there be some error when the query runs, as it can't find the temp table it expects to be there?

The end goal for all of this is to create a routine that cleans out TempDB tables on a nightly basis.

Thanks

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,091 on at
    RE: Can I drop/delete TempDB Tables that AX has created

    Hi wrigh2uk,

    I had a similar issue with temp tables in one of our customers and if I remember there was some kind of bug in AX. When you stop AOS service (properly) it will drop all temp tables from the database automatically, but it will take a lot of time (in my case it could take up to several hours to stop AOS). The fastest way it too forces AOSes to stop and restart SQL server instance.

  • wrigh2uk Profile Picture
    5 on at
    RE: Can I drop/delete TempDB Tables that AX has created
    [quote]

    At least I would not recommend deleting them when the system (AOS) is running.

    It's pretty common to see runtime errors if SQL Server was down, and AOS services were not restarted - AOS is trying to access temp tables that don't exist anymore.

    [/quote]

    Hi Nikolaos thanks for the reply. 

    Would it be correct to assume that while AOS is running it is aware of the temp tables that exists, and may attempt to use those tables again?

    If so would the solution be to stop AOS services, delete the tables and then restart the AOS?

  • Suggested answer
    nmaenpaa Profile Picture
    101,158 Moderator on at
    RE: Can I drop/delete TempDB Tables that AX has created

    At least I would not recommend deleting them when the system (AOS) is running.

    It's pretty common to see runtime errors if SQL Server was down, and AOS services were not restarted - AOS is trying to access temp tables that don't exist anymore.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,469 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,066 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans