How to kill spid 101,101,102,.......300

  • One of our developers created a whole lot of consecutive unwanted spids. I tried this:

    declare @i as int

    set @i = 101

    while (@i <= 300)

    begin

    set @i = @i + 1

    kill @i

    end

    and found that "kill" does not like the use of @i. How would you do this?

    TIA,

    barkingdog

  • declare @i as int

    declare @sql varchar(20)

    set @i = 101

    while (@i <= 300)

    begin

    set @sql = 'kill ' + cast(@i as varchar(4))

    execute (@sql)

    set @i = @i + 1

    end

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

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