Solved

sql2000 having so many process with sleeping status

Posted on 2007-03-24
3
989 Views
Last Modified: 2012-05-05
Hi,
Currently sql process showing 1500+ process which most of them are with "sleeping" status and only 20 processes are running, I would like to know how could I kill all the "sleeping" status without restarting the mssqlserver services  and I dont think kill the spid one by one is the greate idea, anyone could help me here??
0
Comment
Question by:motioneye
3 Comments
 
LVL 29

Expert Comment

by:Nightman
ID: 18785617
The quickest way to kill them all would be to terminate the application that has them open. It sounds as if whatever code is connecting to the database is not explicitly disposing of the database connections.
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18785633
0
 

Author Comment

by:motioneye
ID: 18785731
Hi,
I install the sp and run it in test server which only having 25 processes with 10 process with sleeping status and need to be kill but it takes really really long times and it end up with I stop the query, do u know why???

CREATE PROCEDURE dbo.KillAllProcesses @dbName varchar(50)


AS

BEGIN

SET NOCOUNT ON

DECLARE @spid INT,

@cnt INT,

@sql VARCHAR(255)

SELECT @spid = MIN(spid),@cnt = COUNT(*)

FROM master..sysprocesses

WHERE dbid = DB_ID(@dbname) AND spid != @@SPID AND status = 'sleeping'

WHILE @spid IS NOT NULL

BEGIN

SET @sql = 'KILL ' + RTRIM(@spid)

EXEC ( @sql )

SELECT @spid = MIN(spid),@cnt = COUNT(*)

FROM master..sysprocesses

WHERE dbid = DB_ID(@dbname) AND spid != @@SPID AND status = 'sleeping'

END

END

GO
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how the fundamental information of how to create a table.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now