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)
 temp table usage

Author  Topic 

BitShift
Yak Posting Veteran

98 Posts

Posted - 2006-09-26 : 08:56:22
I have a stored procedure with a select statement setup like so:

select .....

into #tsum

from ...

where ...

select a.* from #tsum a

My question is this:
This works, but dont you have to define your temp table structure
first ?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-26 : 09:03:05
No. When using SELECT INTO, the temp table is using the same structure as the source(s) used in the SELECT statement.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-26 : 11:03:14
Note that the indexes are not available in temp table if you use SELECT INTO

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Westley
Posting Yak Master

229 Posts

Posted - 2006-09-26 : 11:10:50
eekk, and inside a stored proc, it will have to recompile again since the temp table doesn't exists in design time, so it will need to recompile in run time......we got some script (bad ones) that have so many temp tables inside a stored proc, and it just so slow.....
Go to Top of Page
   

- Advertisement -