DECLARE @Stmt VARCHAR(1000) SET @Stmt = '' SELECT @Stmt = @Stmt + 'KILL ' + CONVERT(NVARCHAR(3), [spid]) + '; ' FROM [master].[dbo].[sysprocesses] WHERE DB_NAME([dbid]) = 'TestDb' AND [dbid] <> 0 AND spid <> @@spid EXECUTE(@Stmt) GO
DECLARE @Stmt VARCHAR(1000) SET @Stmt = '' SELECT @Stmt = @Stmt + 'KILL ' + CONVERT(NVARCHAR(3), [spid]) + '; ' FROM [master].[dbo].[sysprocesses] WHERE DB_NAME([dbid]) = 'TestDb' AND [dbid] <> 0 AND spid <> @@spid EXECUTE(@Stmt) GO