Kill All User Sessions

  • Comments posted to this topic are about the item Kill All User Sessions

  • I used a modifed version to block users from my database. Instead of using a cursor you can use...

    declare @out nVarchar(4000)

    SELECT @out = COALESCE (RTRIM(@out)+' Kill ' ,'')+ cast(spid as varchar(10))

    from master..sysprocesses where db_name(dbid) = 'myDatabase' AND NT_USERNAME like @uid

    set @out= 'kill ' + @out

    execute sp_executesql @out

  • DECLARE @sql VARCHAR(8000)

    SELECT @sql=COALESCE(@SQL, '') + 'KILL ' + CAST(SPID AS VARCHAR(10)) + '; '

    FROM SYS.SYSPROCESSES

    SELECT @sql

    EXEC(@SQL)

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply