Our client’s database admins have requested that we don’t use temp tables within our reporting stored procedures (#Table), but instead, make use of table variables.
Are table variables less efficient than temp tables?
Also, if I create a table as #table, as opposed to ##table, the one with one # is a session table, as opposed to the ## which is global, right? When the stored procedure is completed, and you don’t do a DROP TABLE #table … does #table still exist? If it’s session based, then will I ever have access to it again?
Table variables can lead to fewer stored procedure recompilations than temporary tables (see KB #243586 and KB #305977), and — since they cannot be rolled back — do not bother with the transaction log.
##tableis belogs to global temporary table. yes #table not exist because its in given scope only and you never access it out the given scope.Edit
I also like to point make use of CTE(Common Table Expressions) because it also somehow work as temporary table.
Check this answer for detail : Which are more performant, CTE or temporary tables?