- DECLARE @DatabaseName nvarchar(50)
- --Set the Database Name
- SET @DatabaseName = N'TESTDB'
- --Select the current Daatbase
- SET @DatabaseName = DB_NAME()
- DECLARE @SQL varchar(max)
- SET @SQL = ''
- SELECT @SQL = @SQL + 'Kill ' + Convert(varchar, SPId) + ';'
- FROM MASTER..SysProcesses
- WHERE DBId = DB_ID(@DatabaseName) AND SPId <> @@SPId
- and spid IN (SELECT blocked FROM master.dbo.sysprocesses)
- exec @SQL
No comments:
Post a Comment