Re: Can I avoid temp tables, etc.



On your sample SPs you don't show

Set NOCOUNT ON

If you add that to your procs you should see an improvement on
performance because the SP won't be wasting time counting rows to return
and return a count.

As for the tempt tables, wherever you are createing a temp table - just
convert that to a subquery. The temp table is usually a list you are
comparing against for Exists/Not Exits. Well, at least if you are,
for those temp tables, you can convert them to subqueries. This should
improve performance a little because you won't be using resources to
create a table.

All you have to do to make the temp table a subquery is wherever you
have

Create Procedure sp_...
as
Insert Into .....

just grab the Insert Into ... code and change it to

Where Exits
(Select ... from tblX t1 where mainTbl.ID = t1.ID)

Rich

*** Sent via Developersdex http://www.developersdex.com ***
.



Relevant Pages

  • Re: Select question
    ... I don't have presentation layer at all. ... creating view is always the best solution when you have to repeat the ... derived table or is it faster to repeat the subquery? ... > Other alternatives would involve temp tables, ...
    (microsoft.public.sqlserver.programming)
  • Re: Temporary Disk
    ... By clause of the subquery: this field has no place there because the only ... only after the append query, ... the compact and repair after each error message. ... I found the temp file Access is using but not sure how to change size ...
    (microsoft.public.access.queries)
  • Re: how can I avoid NOT IN
    ... Using NOT IN with a subquery is a different matter, ... > (trancode int, ... > insert into #temp values ...
    (microsoft.public.sqlserver.programming)
  • Re: Temp files in Stored Procedures
    ... A subquery is inside the scope of a query; ... putting the result of each step into a temp table. ... Sort of mimicking the way we used to design mag tape systems; ...
    (microsoft.public.sqlserver.programming)
  • Re: DB LOCKS
    ... The volume of procs are very heavy, business logic in these procs is being written from several years. ... Do you have any jobs backing up your temp. ... I don't think that's the reason why ... > SQL DBA ...
    (microsoft.public.sqlserver.server)