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
 SQL Server Development (2000)
 Temporary Tables

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-09-05 : 09:41:54
Gabriela writes "We have a stored procedure that creates a temp table(#a) and then joins #a with other tables to create the result set that feeds to crystal report. This procedure was called from our application frontend and had been taking only couple seconds to display the result. Came Sunday afternoon, it stalled and the users killed the session. I tried it and it took 12 minutes to produce the report!

Here is the portion of the procedure that create the temp table:

select ....(fields from tables & derived tables)
into #a
from ....(6 big tables with join)
where ....(not very complex)
order by ...

My quick fix was:
-create the temp first without populating the data
select ....
into #a
from ....
where 0=1
order by ...
- then insert the data to #a
insert #a
select ....
from ....
where ....
order by ...

I understand the problem should NOT happen with SQL 7.0 and the fix is for SQL 6.5. Any ideas why it happened? My database is close to 9GB and the tempdb is set at 200MB with auto grow at 10%

Any help or suggestions is appreciated. Thanks."
   

- Advertisement -