Paul Gu | Blog

sharing is caring

Local Temporary Table

Here is a simple to create and drop temp tables:

to think that ALL temp tables reside in tempdb database, not releated to the user database at all, and it’s same for Global temp tables (##temp) which is why this would work in any User database.

IF OBJECT_ID(‘tempdb.dbo.#tempTable’) IS NOT NULL

   DROP TABLE #tempTable

CREATE TABLE #tempTable (id smallint)

Next Post

Previous Post

Leave a Reply

© 2024 Paul Gu | Blog

Theme by Anders Norén