SQL Server 2000 Service Pack 3 introduced this new, supposedly useful, function, fn_get_sql. This is like dbcc inputbuffer() but is meant to have advantages, specifically:-
- it can return more than 256 characters of a spid's inputbuffer
- it can return more than just the execution of a stored procedure, it can give you the SQL an SP is executing, or if an SP calls another SP, it can give you the called SP rather than just the calling SP.
Well, that's all fine 'n' dandy, but can you get it to work??? I can't. Whenever I try to use it, I get no results.
I am using the following syntax (copied from BOL):-
DECLARE @Handle binary(20)
SELECT @Handle = sql_handle FROM sysprocesses WHERE spid = 52 --spid obviously changed to be an active one!
SELECT * FROM ::fn_get_sql(@Handle)
Am I doing anything wrong? Anyone else had any joy using it?
I can get info out of dbcc inputbuffer(), but this new function is not working "as it says on the tin", so to speak.
Tom Pullen
DBA, Oxfam GB