• I saw a great presentation on temp tables and table variables that explored, among other things, the different approaches to creating temp tables. it punched holes in many of the different approaches. The safe one was determined to be the one that Luis posted:

    Luis Cazares (1/29/2016)


    IF OBJECT_ID('tempdb.dbo.#tablename, 'u') IS NOT NULL DROP TABLE #tablename;

    I use the same approach to create new stored procedures and functions in the initial release script. After they're created and in production, I alter them with ALTER statements. Either way, the procedure cache is invalidated, so it has to be recreated during the first run.