Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it necessary to use # for creating temp tables in SQL server?

Is it necessary to use # before creating a temporary table in SQL server?

Example:

SELECT column1, column2, someInt, someVarChar  INTO ItemBack1  FROM table2 WHERE table2.ID = 7 

For ItemBack1 is it necessary to use the # symbol?

If not, then what is the use of # in creating temp tables?

like image 632
Arun CM Avatar asked May 25 '13 11:05

Arun CM


People also ask

Is toner really necessary?

No, toning is not necessary for skin health. Toners were originally developed to remove soap scum from the face when lye-based soaps combined with hard water left a sticky residue post cleansing. The alcohol-based toner removed the soap scum eliminating irritation and contributing to cleanser mildness.

Is toner necessary for oily skin?

"Toners are most helpful and necessary for people with oily or acne-prone skin, or for people who want extra cleansing after wearing makeup or other heavy skin products such as sunscreen," she said. If you're wondering what else face toner does for your skin, King outlined some additional benefits: It shrinks pores.

Can I skip toner?

Originally toners were used to pH balance the skin after using a cleanser. Since you can easily get pH-balanced cleansers these days, toners are no longer necessary in a skincare regimen, says Dr. Ted Lain, board-certified dermatologist and chief medical officer at Sanova Dermatology.

Can I skip toner and use moisturizer?

It can be a 'yes' or a 'no' too. 1. Some toners are humectants, which means they attract moisture. So, if your skin is extremely oily and if you feel your toner provides enough moisture, you can definitely skip the moisturizer.


1 Answers

Yes. You need to prefix the table name with "#" (hash) to create temporary tables.

If you do NOT need the table later, go ahead & create it. Temporary Tables are very much like normal tables. However, it gets created in tempdb. Also, it is only accessible via the current session i.e. For EG: if another user tries to access the temp table created by you, he'll not be able to do so.

"##" (double-hash creates "Global" temp table that can be accessed by other sessions as well.

Refer the below link for the Basics of Temporary Tables: http://www.codeproject.com/Articles/42553/Quick-Overview-Temporary-Tables-in-SQL-Server-2005

If the content of your table is less than 5000 rows & does NOT contain data types such as nvarchar(MAX), varbinary(MAX), consider using Table Variables.

They are the fastest as they are just like any other variables which are stored in the RAM. They are stored in tempdb as well, not in RAM.

DECLARE @ItemBack1 TABLE (  column1 int,  column2 int,  someInt int,  someVarChar nvarchar(50) );  INSERT INTO @ItemBack1 SELECT column1,         column2,         someInt,         someVarChar    FROM table2  WHERE table2.ID = 7; 

More Info on Table Variables: http://odetocode.com/articles/365.aspx

like image 155
mobiledaemon Avatar answered Oct 09 '22 15:10

mobiledaemon