Sqlsever Kill locked process

SET QUOTED_IDENTIFIER ON
SET ANSI_NULLS ON
GO


-- =============================================
-- Author:        
-- Create date: <2014-04-16>
-- Description:    
-- =============================================
CREATE PROCEDURE [dbo].UP_Lock_Kill
AS
BEGIN
    DECLARE @sql VARCHAR(100) 
    WHILE 1 = 1 
        BEGIN 
            SELECT TOP 1
                    @sql = 'kill ' + CAST(spid AS VARCHAR(3))
            FROM    master..sysprocesses
            WHERE   spid > 50
                    AND spid <> @@spid 
            IF @@rowcount = 0 
                BREAK 
            EXEC(@sql) 
        END
END


GO

 

转载于:https://www.cnblogs.com/machaofast/p/4368623.html

你可能感兴趣的:(Sqlsever Kill locked process)