Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 append to #table

Author  Topic 

jtwork
Yak Posting Veteran

82 Posts

Posted - 2007-09-26 : 11:36:26
is it possible to insert into #table (a tempoary table?)

If not is the easiest way to create a physical table and then transfer the data into a temp table?

Van
Constraint Violating Yak Guru

462 Posts

Posted - 2007-09-26 : 11:38:30
Yes, you can insert into a #table. Keep in mind that when your session ends that the #table gets dropped automatically.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-09-26 : 12:14:07
"If not is the easiest way to create a physical table and then transfer the data into a temp table?"

We try not to do that on production database because it pollutes the table "name space", and tends to extend the logs in an erratic fashion!

When we do have a need to do this we try to create them in a separate database, so the "pollution" is not in the Production database, and we always name them TEMP_xxx_YYMMDD so that the housekeeping of them becomes pretty obvious after-the-fact.

So inserting into a #table would be preferable (or even a @TableVar one) if the data is only needed within the session, as Van pointed out.

Kristen
Go to Top of Page

jtwork
Yak Posting Veteran

82 Posts

Posted - 2007-09-26 : 12:47:58
many thanks
Go to Top of Page
   

- Advertisement -