CREATE PROCEDURE [dbo].[vspKillDBSessions]
(
@databaseName VARCHAR(200)
)
AS
AS
SET NOCOUNT ON
DECLARE @killStr NVARCHAR(4000);
WITH killList (killStr)
AS(
SELECT ' KILL ' + CAST(spid AS VARCHAR(5)) + CHAR(10) FROM master..sysprocesses
WHERE dbid = db_id(@databaseName)
FOR XML PATH(''), TYPE
)
SELECT @killStr = CAST (killStr AS NVARCHAR(4000) ) FROM killList;
EXEC sp_executesql @killStr
No comments:
Post a Comment