I was wondering, what is the difference between these two scripts?
SELECT * FROM ##TEMP
and this
SELECT * FROM #TEMP
##TEMP
is global temporary table, #TEMP
is local.
Local temporary tables are visible only to their creators during the same connection to an instance of SQL Server as when the tables were first created or referenced. Local temporary tables are deleted after the user disconnects from the instance of SQL Server.
Global temporary tables are visible to any user and any connection after they are created, and are deleted when all users that are referencing the table disconnect from the instance of SQL Server.
see documentation.
Actually here is almost the same question with answer - Local and global temporary tables in SQL Server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With