July 22, 2009 at 5:54 am
Peter - silly question i know but did you actually put the KPID id in the script where it says to?
July 22, 2009 at 9:29 am
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
July 22, 2009 at 9:58 am
July 22, 2009 at 10:02 am
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 🙂
July 22, 2009 at 10:18 am
July 22, 2009 at 11:15 am
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