Killing A Process

  • Dear All,

    Is there an alternative way of killing a process besides on the enterprise manager. The thing is that I've tried several times to do it on the Entprise Manager but then it doesn't work. The only way to get the uers off is to restart the sever of which is the bad pratice. Please help me.

     

  • You can Kill Proccess from QA using KILL method.

    KILL SPID(SPID of the proccess)

    Thanks,

    SR

     

     

     

    Thanks,
    SR

  • You can even use script if you want to kill all processes from any specific database.

    Here is the Script

    Create procedure usp_killprocess @dbname varchar(128) as

    set nocount on

    set quoted_identifier off

    declare @kill_id int

    declare @query varchar(320)

    declare killprocess_cursor cursor for

    select a.spid from sysprocesses a join

    sysdatabases b on a.dbid=b.dbid where  b.name = @dbname

     

    open killprocess_cursor

    fetch next from killprocess_cursor into @kill_id

    while(@@fetch_status =0)

    begin

    set @query = 'kill '+ convert(varchar,@kill_id)

    exec (@query)

    fetch next from killprocess_cursor into @kill_id

    end

    close killprocess_cursor

    deallocate killprocess_cursor

    --exec usp_killprocess "mydatabasename"

    GO

    SET QUOTED_IDENTIFIER OFF

    GO

    SET ANSI_NULLS ON

    GO

    Hope this helps,

     

     

    Kindest Regards,

    Sameer Raval [Sql Server DBA]
    Geico Insurance
    RavalSameer@hotmail.com

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

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