SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON GO -- ============================================= -- Author: <machao> -- Create date: <2014-04-16> -- Description: <kill all lock in db> -- ============================================= 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