What is the difference between #temptable and ##TempTable in SQL Server?
simple way of testing #localtable and ##globaltable
Try this in a different SQL Query Window
create table ##globaltemptable (id int )
go
insert into ##globaltemptable values (1)
go
select * from ##globaltemptable
Try this in a different SQL Query Window
create table #localtemptable (id int )
go
insert into #localtemptable values (1)
go
select * from #localtemptable
Now if you run the select query for the table : #localtemptable in the global window syntax , you will get an error as follows :-
Invalid object name '#localtemptable'.
While you run the select query for the table : ##globaltemptable in any query window of the same session, you will get the query results return.