I am using Oracle 11g Global Temporary Tables as I need a solution where I can add rows to a temporary table for a join, and I want only the rows added to the temp table for
Temporary tables in Oracle are permanent objects that hold temporary data that is session local. Temporary tables in SQL Server are temporary objects.
I find that a local temporary table, or table variable, is the closest to being the same to Oracle's global temp table, the big difference is you have to create it every time.
Usually, in a case like yours, step 3, add rows to temp table, would be done by doing a select ... into #temp_table_name .... (equivalent to Oracle create table ... as select ...) http://msdn.microsoft.com/en-us/library/ms188029.aspx
Also, you can't do the following in a stored proc: (pseudo code.)
begin proc
call another proc to create local temp table.
use temp table
end proc
Local temp tables are destroyed when returning from the stored procedure that created them.
Update 2014-10-14: The behavior of local temp tables is different in the Parallel Data Warehousev version of SQL Server. Temporary tables are not dropped on exit from the stored procedure that created them, and instead continue existing for the rest of the session. This behavior observed on:
select @@version
Microsoft SQL Server 2012 - 10.0.5108.1 (X64) Jun 24 2014 20:17:02 Copyright (c) Microsoft Corporation Parallel Data Warehouse (64-bit) on Windows NT 6.2 (Build 9200: )