views:

38

answers:

2

I have a depricated 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

+4  A: 
select hostname from master..sysprocesses where spid=@@SPID

or

select host_name from sys.dm_exec_sessions where session_id=@@SPID
Martin Smith
+1 - And if you have multiple different applications calling the procedure (Query Analyzer, Crystal Reports, etc.) you can select `program_name` as well to narrow it down
LittleBobbyTables
+2  A: 

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

routeNpingme
+1 I forgot that sysprocesses would need to be given in 3 part format.
Martin Smith