Here I just want to play with local temp table behavior inside a stored procedure. I still create and drop temp table inside the same proc.
Below is the sample proc:
/*********************************************/
CREATE PROCEDURE dbo.test2
AS
/*
exec dbo.test2
*/
begin
begin try
CREATE TABLE #test2(test2 int)
return
end try
begin catch
select 'This is inside CATCH statement of proc test2!'
return
end catch
end
GO
/*********************************************/
After I close the query window that runs "exec dbo.test2" and the conn session is supposed to be closed(?). When I open another query window and run the query below:
select * from tempdb.sys.columns
where name in ('test2')
I still see this record there, which means the temp table still exists after the session is closed(?). This column is unique for sure.
Any explanation here?
Thanks.
Shigui,