January 8, 2008 at 12:17 pm
There doesn't seem to be any basic search for the forums so if this has been covered before, I appologize. I am very new to SQL Server (and db admin for that matter).
What is the # used for? The following statement is why I'm asking this question:
select name into #d
from sysusers
Does it represent a dummy table? A column in a dummy table?
Thanks in advance,
Chrys
January 8, 2008 at 12:20 pm
it puts the results of the query into a temporary table name #d
January 8, 2008 at 12:23 pm
more info on temp tables:
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/1e068443-b9ea-486a-804f-ce7b6e048e8b.htm
January 8, 2008 at 6:56 pm
Favorite temp table name... #MyHead 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
January 8, 2008 at 9:32 pm
Hi Chrys204,
This is the temporary table (#d) and it is for current session only. that means for the current query window. moreover this is the local temporary table.
😉
January 9, 2008 at 7:55 pm
January 10, 2008 at 4:21 am
And then there are global temp tables that start with 2 pound signs (##d). These tables are available to any connection using the database so long as there are still connections. Once all the connections are closed, the global temp table is destroyed.
So if I'm connected to MyDB and create ##SillyTempTable, so long as I haven't dropped the table and am still connected, one of my coworkers can connect to MyDB and access ##SillyTempTable also. If I disconnect while coworker is using the table, the table still stays in effect (or should according to MS). But once coworker disconnects (assuming no one else has connected to use it), then the table "vanishes" for good.
Read up in BOL, subject "temporary tables".
January 10, 2008 at 6:01 am
"#MyHead "
Thanks Jeff, for this morning's smile...
January 10, 2008 at 6:59 am
Jeff Moden (1/8/2008)
Favorite temp table name... #MyHead 😀
Pretty close to accurate too - disconnect the session and the table gets wiped:)
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply