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 2000 Forums
 Transact-SQL (2000)
 Select statement --> Temp Table

Author  Topic 

MichaelP
Jedi Yak

2489 Posts

Posted - 2002-03-14 : 19:23:58
Is there any way to auto generate a create table statement for a given large select statement? I really don't want to type in all that stuff, too much room for error.

Michael

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-03-14 : 19:32:46
What about SELECT...INTO? It'll create the table and INSERT the data in one operation:

SELECT col1, col2, col3, col4, col5 INTO #newTempTable FROM oldTable

Be careful if the SELECT statement retrieves a lot of rows, it could hog the server while it's running (and also block tempdb from other processes)

Edited by - robvolk on 03/14/2002 19:33:15
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2002-03-14 : 20:04:08
Rob, as always you are the man with the solution!

Thx for the tip!!

Michael

Go to Top of Page
   

- Advertisement -