开发者

How to identify the caller of a Stored Procedure from within the Sproc

开发者 https://www.devze.com 2023-01-15 10:21 出处:网络
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 t

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.

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

or

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


@@SPID should give you the current process ID.

Then,

select * from master.dbo.sysprocesses where spid = @@SPID

You can get what you need from one of those columns.

0

精彩评论

暂无评论...
验证码 换一张
取 消