Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I recently saw a statement like:

CREATE TABLE #tbl_AR_Data

I wanted to know what is the purpose of the symbol # (NUMBER SIGN, hash, pound sign) in this statement?

share|improve this question

closed as off-topic by Mark Storey-Smith, Mikael Eriksson, Max Vernon, Gaius, RolandoMySQLDBA Jul 11 at 20:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Mark Storey-Smith, Mikael Eriksson, Max Vernon, Gaius, RolandoMySQLDBA
If this question can be reworded to fit the rules in the help center, please edit the question.

3  
It always helps to read the manual: technet.microsoft.com/en-us/library/… –  a_horse_with_no_name Jul 11 at 10:09
4  
The CREATE TABLE documentation is very helpful... msdn.microsoft.com/en-gb/library/ms174979.aspx –  Mark Sinkinson Jul 11 at 10:47

1 Answer 1

up vote 10 down vote accepted

'#' denotes a temporary table.

This tells SQL Server that this table is a local temporary table. This table is only visible to this session of SQL Server. When I close this session, the table will be automatically dropped.

You can treat this table just like any other table with a few exceptions. The only real major one is that you can't have foreign key constraints on a temporary table.

Read about usage and syntax here.

share|improve this answer
2  
Since you mentioned MySQL, I thought I'd point out that the question is about SQL Server. Same, same, but different. –  Max Vernon Jul 11 at 12:37
1  
The question did not specify any particular server, so I explained using SQL server. What do you mean by Same, same, but different. ? –  Nivedita Jul 11 at 12:46
1  
I mentioned SQL server as well. Do you want me to add something in the answer? –  Nivedita Jul 11 at 13:13
2  
It's absolutely fine. I don't mind people trying to correct me. :) –  Nivedita Jul 11 at 13:17
1  
Extra info does no harm. But its fine if you removed it .. :) –  Nivedita Jul 12 at 15:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.