I have a ##table which can be accessed across all the sessions but sometimes I am getting error
There is already an object named \'##table\' in the
So the WHY part has been answered and here is how to resolve it:
Do a check to see if the temp table exists before creating it:
if object_id('tempdb..##table') is null begin
--create table ##table...
end
I found a pretty interesting post about how to check the existence of a temp table from Googling http://sqlservercodebook.blogspot.com/2008/03/check-if-temporary-table-exists.html