The topic describes the DF098 T-SQL code analysis rule.
BEST PRACTICE
A temporary table has been created but not dropped.
To save resources, it is recommended to promptly drop temporary tables that are no longer needed.
Failing to drop temporary tables that are no longer needed can lead to increased resource usage, such as memory and disk space, which can affect overall system performance. Additionally, holding onto unnecessary temporary tables can potentially lead to contention issues and degrade database performance over time. Therefore, it’s advisable to regularly review and drop temporary tables as soon as they are no longer required to optimize resource utilization and maintain efficient database operations.
CREATE TABLE #temp (Id INT NOT NULL);
INSERT INTO #temp(Id) VALUES(12)
SELECT * FROM #temp
GO
CREATE TABLE #temp (Id INT NOT NULL);
INSERT INTO #temp(Id) VALUES(12)
SELECT * FROM #temp
DROP TABLE IF EXISTS #temp
GO