SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 append to #table
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jtwork
Yak Posting Veteran

82 Posts

Posted - 09/26/2007 :  11:36:26  Show Profile  Reply with Quote
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

458 Posts

Posted - 09/26/2007 :  11:38:30  Show Profile  Reply with Quote
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

United Kingdom
22403 Posts

Posted - 09/26/2007 :  12:14:07  Show Profile  Reply with Quote
"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 - 09/26/2007 :  12:47:58  Show Profile  Reply with Quote
many thanks
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000