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)
 Help Insert in a TEMP Table?

Author  Topic 

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2007-11-02 : 14:47:23
What's the syntax to Select ----Into a Temp Table?

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-11-02 : 14:49:14
Dont post dups: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=91994

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-11-02 : 14:51:41
I disagree that this is a duplicate.

The syntax for inserting into a temp table is the same as if it were a regular table. The only difference is that you put # before the object name.

Here are two ways:

SELECT ...
INTO #Temp
FROM ...
WHERE ...

Or

CREATE TABLE #Temp (...)

INSERT INTO #Temp (...)
SELECT ...
FROM ...
WHERE...

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2007-11-02 : 14:55:11
Thanks !!!
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-11-02 : 17:15:42
Looks like something happened there.. for a moment the thread was locked.. I thgt I saw the same question in the other thread.. or is it the friday...

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-11-02 : 17:53:05
I locked it when I saw your post about it being a duplicate. I then looked at both threads more closely and decided to unlock this one.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-11-02 : 18:02:40
quote:
Originally posted by tkizer

I locked it when I saw your post about it being a duplicate. I then looked at both threads more closely and decided to unlock this one.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/



Oops... sorry if I misguided you...

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -