Re: Stored procedure never finishes

From: Randy Danielson (no_freakin_spam_at_sickofit.com)
Date: 05/10/04


Date: Mon, 10 May 2004 13:12:53 -0700

Thanks for the reply.

I have found that if I don't use temp tables then the stored proc works.
So instead of using temp tables I am simulating temp tables by creating
a table if it doesn't exist else delete all the records from the table.

So I guess this would point to tempdb. Not really sure what to do with
it, but since rebooting the server temporarily fixes the problem would
suggest that some clean up is happening. I thought that stopping and
restarting the sql server would have done the same clean up, but
apprantly not.

Do you know what this clean up would be that happens during a reboot?

Thanks

Randy

In article <ui7yCTpNEHA.628@TK2MSFTNGP11.phx.gbl>, "Greg Linwood"
<g_linwoodQhotmail.com> says...
> Hi Randy
>
> The information in your post seems to suggest a few wierd things. The fact
> that stopping / starting doesn't make a difference indicates a potential
> logic problem. The information that providing the date range helps indicates
> that you may have a run away query (this can't be fixed by restarting the
> services).
>
> Perhaps when you run the query without the date range, your server simply
> runs out of resources? Have you checked that the connection that the query
> is running on is holding locks? This would indicate that it's definitely
> still active. You do this by issuing "exec sp_lock [spid]" with spid being
> the connection identifier for the connection running the proc (obtained by
> running select @@spid before running the proc). Perhaps the query's being
> blocked by another process? You check that by running "exec sp_who2 [spid]".
>
> You should also check the execution plan of the query to see if it's
> scanning large tables & consider creating indexes that might help speed the
> query up. The Index Tuning Wizard might help you there.
>
> These are just a few ideas.
>
> Regards,
> Greg Linwood
> SQL Server MVP
>
> "Randy D" <no_freakin_spam@sickofit.com> wrote in message
> news:MPG.1b07f34f310bc9c998968a@news.supernews.com...
> > Hello everyone,
> >
> > I have a stored proc that won't finish. I am testing it directly from
> > query analyzer. If we reboot the server then the stored procedure will
> > finish, but only for the first day. I can only test the stored proc on
> > the weekends or in the evening when everyone is not using the system
> > because it is fairly resource intensive.
> >
> > When the stored procedure hangs SQL server is not consuming any
> > processor cycles, but the timer in query analyzer continues to count.
> >
> > At first I thought it was not enough free space in the tempdb and
> > database where the stored proc is running. We increased the size
> > significantly with no effect.
> >
> > Stopping and restarting sql agent and sql server does not make a
> > difference either. What is happening during a reboot?
> >
> > Also if I run the stored proc with a date range in the where clause it
> > will finish properly.
> >
> > SQL Server 2K



Relevant Pages

  • Re: Stored procedure never finishes
    ... Perhaps when you run the query without the date range, ... You do this by issuing "exec sp_lock [spid]" with spid being ... SQL Server MVP ... > I have a stored proc that won't finish. ...
    (microsoft.public.sqlserver.server)
  • Re: Table Variable vs Temporary Table
    ... internally very much the same way as temp tables (on difference is that there is slightly less ... Tibor Karaszi, SQL Server MVP ... > alot of data and the server doesn't have not RAM/memory, ... >> We have a query that declares a table variable, ...
    (microsoft.public.sqlserver.programming)
  • Re: the higher the cos , the faster?
    ... > believe to be the best order of operations to do the query. ... > can check all of the possible ways of executing the query, ... > possible to let SQL Server do its thing. ... > would I even consider using temp tables. ...
    (microsoft.public.sqlserver.programming)
  • RE: No Foreign Keys retrieved
    ... I'm not really sure but you could try creating a stored proc in sql server ... My query runs fine but none of the foreign key ... The foreign key values are FirmID, InHouseCounsel, DepartmentPayingID, ...
    (microsoft.public.access.modulesdaovba)
  • Re: T-SQL how to deal with results from stored proc
    ... > My attempt was to use INSERT EXEC to fetch te results of several ... In a wrapping stored proc I intended to collect data ... You can also use temp tables, as I discuss in the article I pointed you to. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (comp.databases.ms-sqlserver)