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

后端 未结 2 2124
广开言路
广开言路 2021-02-14 01:19

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

相关标签:
2条回答
  • 2021-02-14 01:36

    @@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 讨论(0)
  • 2021-02-14 01:56
    select hostname from master..sysprocesses where spid=@@SPID
    

    or

    select host_name from sys.dm_exec_sessions where session_id=@@SPID
    
    0 讨论(0)
提交回复
热议问题