DEFINITIONS

Definitions More Info.
Definition ID153
TitleSQL
CategoryMS_SCRIPT
DefinitionKillingUserConnectionConnectedToTheDatabase
Definition DescriptionDECLARE @SPID varchar(8000)
DECLARE @Conntions_Killed smallint
DECLARE @DBName varchar(100)
SET @SPID = ''
SET @Conntions_Killed = 0;
SET @DBName = 'GURMEN'
-- Pass the Database Name.
SELECT @SPID=coalesce(@SPID,',' )+'KILL '+convert(varchar, spid)+ '; '
FROM MASTER..SYSPROCESSES WHERE dbid=db_id(@DBName);
Print @SPID; IF LEN(@SPID) > 0
BEGIN EXEC(@SPID);
SELECT @Conntions_Killed = COUNT(1)
FROM master..sysprocesses
WHERE dbid=db_id(@DBName) END
RecordBycunay
Record Date21-02-2012 12:24:45
Düzenle
Kopyala
Sil