You could create a storedproc in master that kills any existing spids per db, then run that proc from DMO as part of the restore job.. something like this
CREATE procedure sp_KillOldspids
@.dbName varchar (30) = NULL
AS
set nocount on
declare @.currentspid int,@.cmdstring varchar(30)
dECLARE OPENSPIDS CURSOR FOR SELECT [SPID] from [MASTER].[DBO].[SYSPROCESSES] WHERE DBID = db_id (@.dbName)
OPEN OPENSPIDS
FETCH NEXT FROM OPENSPIDS INTO @.CURRENTSPID
WHILE @.@.FETCH_STATUS = 0
BEGIN
SELECT @.cmdString = 'kill ' + convert(varchar(10), @.CURRENTspid)
IF @.@.SPID <> @.CURRENTSPID
BEGIN
EXEC (@.cmdString)
END
FETCH NEXT FROM OPENSPIDS INTO @.CURRENTSPID
END
CLOSE CURRENTSPIDS
DEALLOCATE CURRENTSPIDS
hopes this helps.
No comments:
Post a Comment