Solved

sql2000 having so many process with sleeping status

Posted on 2007-03-24
3
986 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

762 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

16 Experts available now in Live!

Get 1:1 Help Now