I am working on creation of temporary tables in sql server. I created the temporary table successfully but when I try to view the data it says INVALID OBJECT NAME.
Can anyone pls tell foe how long temporary tables exists?
If I am logged on to sql server as userid – devloper and pwd = 0999 and someother person is also logged on to the sql server with same credentials, this temporary tables will get deleted?
my sql is as follows:
SELECT net_node_model.SYS_ID, net_node_model.NODE, mst_temp_equation.TEMP_ID,
mst_temp_equation.EQ_ID
INTO ##NT_MASTER_TEMP_EQUATION
FROM mst_temp_equation INNER JOIN
net_node_model ON mst_temp_equation.TEMP_ID = net_node_model.TEMP_ID
GROUP BY net_node_model.SYS_ID, net_node_model.NODE, mst_temp_equation.TEMP_ID,
mst_temp_equation.EQ_ID, mst_temp_equation.EQ_NAME,
mst_temp_equation.EQ_TYPE, mst_temp_equation.[OBJECT],
mst_temp_equation.VAR_TYPE, mst_temp_equation.VAR_NAME,
mst_temp_equation.VAR_SUBSET, mst_temp_equation.VAR_SET,
mst_temp_equation.RHS_RELN, mst_temp_equation.RHS_OBJECT,
mst_temp_equation.RHS_VAR_SET, mst_temp_equation.RHS_VAR_SUBSET,
mst_temp_equation.RHS_VAR_TYPE, mst_temp_equation.RHS_VAR_NAME,
mst_temp_equation.EQ_TP_OFFSET, mst_temp_equation.RHS_TP_OFFSET,
mst_temp_equation.RETAIN, mst_temp_equation.TIME_PRD,
mst_temp_equation.EQ_VAR_SUBTYPE, mst_temp_equation.RHS_VAR_SUBTYE;
If you are using a regular temporary table
#table, it will not be visible to any other session apart from the one it was created on. Once that session is finished, the table will be removed.If you are using a global temporary table
##table, it will be visible to other sessions.From MSDN –
CREATE TABLE, undertemporary tables: