title: DROP TABLE fails for temp table
body: <p>I have a client application that creates a temp table, the performs a bulk insert into the temp table, then executes some SQL using the table before deleting it.</p>
  
  <p>Pseudo-code:</p>
  
  <pre><code>open connection
  begin transaction
  CREATE TABLE #Temp ([Id] int NOT NULL)
  bulk insert 500 rows into #Temp
  UPDATE [OtherTable] SET [Status]=0 WHERE [Id] IN (SELECT [Id] FROM #Temp) AND [Group]=1
  DELETE FROM #Temp WHERE [Id] IN (SELECT [Id] FROM [OtherTable] WHERE [Group]=1)
  INSERT INTO [OtherTable] ([Group], [Id]) SELECT 1 as [Group], [DocIden] FROM #Temp
  
  DROP TABLE #Temp
  COMMIT TRANSACTION
  CLOSE CONNECTION
  </code></pre>
  
  <p>This is failing with an error on the DROP statement:</p>
  
  <p>Cannot drop the table '#Temp', because it does not exist or you do not have permission.</p>
  
  <p>I can't imagine how this failure could occur without something else going on first, but I don't see any other failures occurring before this.</p>
  
  <p>Is there anything that I'm missing that could be causing this to happen?</p>