如何从 Sproc 中识别存储过程的调用者 [英] How to identify the caller of a Stored Procedure from within the Sproc

查看:31
本文介绍了如何从 Sproc 中识别存储过程的调用者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个已弃用的存储过程,它不应再从代码中调用,但仍有一些系统仍在调用它.这是一台生产服务器,因此我对它进行诊断的间接访问非常有限.

I have a deprecated stored procedure which should no longer be called from code, but there is some system which is still calling it. This is a production server so I have very limited indirect access to it for performing diagnostics.

有没有办法确定从 sproc 中调用特定存储过程的机器?诸如@@CallingMachineIP 或@@CallingMachineName 之类的东西

Is there any way to determine the machine which is calling a particular stored procedure from within the sproc? Something such as @@CallingMachineIP or @@CallingMachineName

推荐答案

select hostname from master..sysprocesses where spid=@@SPID

select host_name from sys.dm_exec_sessions where session_id=@@SPID

这篇关于如何从 Sproc 中识别存储过程的调用者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆