11

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

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Chris Ballance
  • 33,810
  • 26
  • 104
  • 151

2 Answers2

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

or

select host_name from sys.dm_exec_sessions where session_id=@@SPID
Martin Smith
  • 438,706
  • 87
  • 741
  • 845
6

@@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.

Brandon
  • 13,956
  • 16
  • 72
  • 114