Track down runaway CPU spikes

  • Peter - silly question i know but did you actually put the KPID id in the script where it says to?

  • This is what I have:

    USE master

    GO

    -- returns SPID & DBCC INPUTBUFFER for a given kpid

    DECLARE @sql nvarchar(1000), @spid int, @ParamDef nvarchar(1000)

    SET @ParamDef = N'@spidOUT int OUTPUT'

    SET @sql = N'SELECT @spidOUT = spid '

    + 'FROM master..sysprocesses '

    + 'WHERE kpid = ' 7116

    EXEC sp_executesql @sql, @ParamDef, @spidOUT = @spid OUTPUT

    SET @sql = N'SELECT @spidOUT AS [SPID];dbcc inputbuffer('

    + CAST(@spid AS nvarchar(3)) + N')'

    EXEC sp_executesql @sql, @ParamDef, @spid

    Server: Msg 170, Level 15, State 1, Line 8

    Line 8: Incorrect syntax near '7116'.

    Tried a few variations of (') but no luck

  • Peter D (7/22/2009)

    + 'WHERE kpid = ' 7116

    kpid is numeric, so you should change that to:

    + 'WHERE kpid = 7116 '

    _______________________________________________________________________
    For better assistance in answering your questions, click here[/url]

  • Richard M (7/22/2009)


    Peter D (7/22/2009)

    + 'WHERE kpid = ' 7116

    kpid is numeric, so you should change that to:

    + 'WHERE kpid = 7116 '

    its not because its numeric, its because its outside of the dynamic string build. your code fixes it though 🙂

  • ... I know.. I just wanted it to be as simple as possible for the OP 😉

    _______________________________________________________________________
    For better assistance in answering your questions, click here[/url]

  • thnxs guys, all is good!

Viewing 6 posts - 16 through 20 (of 20 total)

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