• SQLRNNR (10/22/2012)


    sqldba_newbie (10/22/2012)


    Vegard Hagen (10/22/2012)


    Most likely you've come across a piece of bad application code that doesn't clean up after itself.

    All temporary objects created in tempdb must be dropped when you're done with them.

    You can check this by running a trace and looking at the actual SQL code. Anything that's created and not dropped at the end of a transaction is part of the problem.

    So within a stored procedure, if i am creating any temp tables they should also be dropped? My understanding was temp tables are dropped after the session is completed?

    In many cases that is true. Sometimes the temp table will not clean up after the session is closed. It is typically good practice to clean up these objects - it's only an extra line of code.

    That said, what do you mean by tempdb space not being released?

    Do you mean that tempdb data files and log file are full and the space is not being released internally or do you mean that tempdb is not shrinking and releasing space to the OS?

    tempdb data files and log file are full and the space is not being released internally