Solved

sql2000 having so many process with sleeping status

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

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

820 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