none
Kill process error: only user processes can be killed

    Question

  • Hi,
    I run a Stored like sa/admin...and before the begin of a transaction call this SP for kill all the process.
    -----------------
    DECLARE @KILL_ID int
    DECLARE @QUERY VARCHAR(320)

    DECLARE GETEXCLUSIVE_CURSOR CURSOR FOR

    --get all SPIDs from SYSOBJECTS table which match our database
    SELECT
        A.SPID
    FROM SYSPROCESSES A
    JOIN SYSDATABASES B ON A.DBID = B.DBID
    WHERE B.NAME=@DBNAME

    OPEN GETEXCLUSIVE_CURSOR
        FETCH NEXT FROM GETEXCLUSIVE_CURSOR INTO @KILL_ID

        WHILE(@@FETCH_STATUS =0)
        BEGIN

            --form drop trigger query
            SET @QUERY = 'KILL '+ CONVERT(VARCHAR,@KILL_ID)

            EXEC (@QUERY)
            FETCH NEXT FROM GETEXCLUSIVE_CURSOR INTO @KILL_ID
        END

    CLOSE GETEXCLUSIVE_CURSOR
    DEALLOCATE GETEXCLUSIVE_CURSOR
    ---------------

    After 5 days fine today got an error message that failure my SP:
    only user processes can be killed

    Now how I must kill only the real process of user and not thet one of system?
    I think this the problem
    TNKS Alen Italy
    Monday, July 14, 2008 3:33 PM

Answers

All replies