When using temporary tables in stored procedures, SQL Server is the preferred practice:
1) Create a temporary table, fill it in, use it, then lower it
CREATE TABLE
2) Check if it exists, discard it if that happens, then create and use it
IF object_id('tempdb..#MyTable') IS NOT NULL DROP TABLE
3) Create it and let SQL Server clean it when it goes out of scope
CREATE TABLE
I read in this answer and related comments that it can be useful in situations where the temporary table is reused so that SQL Server truncates the table but saves it to save time.
My stored process will most likely be called quite often, but it contains only a few columns, so I donโt know how beneficial this is in my situation.
source share