Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

# vs ## ?

Status
Not open for further replies.

sagn

Programmer
Jun 7, 2001
166
US
Could anyone explain to me the precise difference
between using

# and ## in statements like

select *
into #temptable

and

select *
into ##temptable


Thanks

ds

 
the # is a procedure localized temporary table, while the ## is a global temporary table.


hope this helps
leo
 
Hi there,
The Tables/ Procedure e.t.c created with '#' are valid for a single session. As soon as the session is disconnected either requested by user or because of some connection problem, the '#' objects are droped.
Whereas, '##' objects are droped only when the next time the server will be restarted. I.e. a '##' object created by a user can be used by him or others, till the sql server is not restarted.
 
Hi There

#Temptable
A private temporary table. Only the connection that created it can access it. Therefore it is really private.. They exist for the life of the session

##Temptable
A global temporary table. Any connection can access it even without special permissions.
They exist until the connection that created it terminates and all current use of the table completes.

Hope this helps
Bernadette
 
Thanks everyone. That is just what I wanted to know!


ds
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top