views:

59

answers:

4

Can someone please explain to me what the # symbol means in MS SQL Code.

I've tried Googling it, and even searching on StackOverflow, but can't seem to find the answer.

I feel like an idiot - having one of "those" days. Please help.

+5  A: 

They normally prefix temporary tables.

From the docs...

Prefix local temporary table names with single number sign (#table_name), and prefix global temporary table names with a double number sign (##table_name).

Ed Guiness
Perhaps better to post a link for SQL Server 2005/2008 nowadays, even if info is still the same...?
gbn
Thnx Ed. Simple answer to a simple question..
Saajid Ismail
+2  A: 

You could be seeing the # in the usage of a temporary table

SELECT
  *
FROM #myTempTable
John Hartsock
Local temp tables. ## is for global temp tables.
HLGEM
+1  A: 

The pound sign # is used to prefix temporary tables and procedures. A single instance (#) refers to a temporary object that lives/dies with the current session while a double instance (##) is a global object.

Michael Haren
+1 For mentioning procedures.
Martin Smith
A: 

#TEMPTABLE. Its actually a type of a temporary table that is scoped for that session.

Baaju