Creating a global temp table in a SQL Agent job I want to create a global temp table in a SQL Server Agent Job.

Here is the code:

CREATE TABLE ##TestEmployee(Id int, EmployeeName nvarchar(50))


When I execute in SSMS, all is well.

I then put the above code on a SQL Agent Job. The job will complete successfully, but when I try doing a select statement in SSMS, I get an Invalid Object error.

SELECT * FROM ##TestEmployee


Are there any gotchas I am missing by creating a global temp table in SQL Server Agent?
The difference between global and local temp tables isn't how long they exist, it's who can see them.

Local temp tables can only be seen by the session (spid) that created them.  Global temp tables can be seen by everyone, but only while the session that created them is active.

If you are running it in a SQL Agent job, as soon as it completes it disappears. That's why you can't access it, because it is no longer there.