我正在使用 Context_Info() 变量来跟踪正在执行存储过程和自由格式 sql 的用户。在解决此服务器上的问题时,每个会话都会通过。我希望能够引入 context_info() 变量的值并基于它进行过滤。
Jacob
问问题
1355 次
1 回答
3
You can use the UserConfigurable Events along with sp_trace_generateevent (EventId's 82-91) when setting the context_info() to output the values to the trace. Your option is to either do that, or trace the statements setting the context_info(). You won't be able to get the value any other way unless you write a process to dump the output of sys.dm_exec_sessions in a loop while the trace is running:
select session_id, cast(context_info as varchar(128)) as context_info
from sys.dm_exec_sessions
where session_id > 50 -- user sessions
for SQL 2000 you can use sysprocesses:
select spid, cast(context_info as varchar(128)) as context_info
from sysprocesses
where sid > 50 -- user sessions
于 2009-06-30T01:15:11.777 回答