Home All Groups Group Topic Archive Search About

Call Stack in SQL Server

Author
10 Aug 2006 11:24 PM
kelly.harrison
Is it possible to get the call stack from within a SQL statement?
Specifically, I'd like to get the statement that causes a trigger to
fire from within the trigger itself. 

Thanks,

-k

Author
11 Aug 2006 1:01 AM
Paul Wehland
DBCC STACKDUMP

But it will give you the stack from every thread, not just your own.  The
stacks are printed to the errorlog.  Make sure your symbols are matched.


<kelly.harri***@gmail.com> wrote in message
Show quote
news:1155252246.626327.78200@75g2000cwc.googlegroups.com...
> Is it possible to get the call stack from within a SQL statement?
> Specifically, I'd like to get the statement that causes a trigger to
> fire from within the trigger itself.
>
> Thanks,
>
> -k
>
Author
11 Aug 2006 6:52 PM
Dean
Kelly,

DBCC INPUTBUFFER will display the last statement sent from the client, for
the given SPID. In order to do anything useful with it, you have to capture
the returned information into a table - something like this:

create table #inp_buff (EventType nvarchar(30), Parameters Int, EventInfo
nvarchar(255))

insert #inp_buff
exec('DBCC INPUTBUFFER(@@spid) WITH NO_INFOMSGS')

select eventinfo from #inp_buff


HTH,

Dean

<kelly.harri***@gmail.com> wrote in message
Show quote
news:1155252246.626327.78200@75g2000cwc.googlegroups.com...
> Is it possible to get the call stack from within a SQL statement?
> Specifically, I'd like to get the statement that causes a trigger to
> fire from within the trigger itself.
>
> Thanks,
>
> -k
>

AddThis Social Bookmark Button