Comments on: How to find who called a stored procedurehttp://itknowledgeexchange.techtarget.com/itanswers/how-to-find-who-called-a-stored-procedure/
Fri, 09 Dec 2016 16:23:18 +0000hourly1By: kccrosserhttp://itknowledgeexchange.techtarget.com/itanswers/how-to-find-who-called-a-stored-procedure/#comment-77615
Fri, 28 May 2010 18:35:37 +0000#comment-77615If you were creating new code, adding a “trail” of breadcrumbs is not a bad idea. From the problem description, it sounded like the code already existed, so modifying all the callers wasn’t a likely option (and there must be more than one, otherwise the question wouldn’t be needed).

One caveat about the sys.sysdepends table mentioned above: it is possible (indeed, very likely) that NOT all the dependencies are properly recorded in the table. In order to make sure that all the dependencies are in there, you should first force an update of the dependencies table by calling:
exec sp_refreshsqlmodule @nameofmodule

Note – because sp_refreshsqlmodule is updating a table, it needs to be in a transaction. If there are SQL modules that will throw errors when “refreshed”, the transaction must be rolled back. Thus the above try..catch logic.

After this is run, the sys.sysdepends table will be correct.

]]>By: oliverahttp://itknowledgeexchange.techtarget.com/itanswers/how-to-find-who-called-a-stored-procedure/#comment-77604
Fri, 28 May 2010 09:44:45 +0000#comment-77604Thanks to both of you.
]]>By: twlp123http://itknowledgeexchange.techtarget.com/itanswers/how-to-find-who-called-a-stored-procedure/#comment-77597
Fri, 28 May 2010 00:52:52 +0000#comment-77597When a process/stored procedure calls a stored procedure, I would pass a string parameter as the name of the process/stored procedure to the called stored procedure. The called stored procedure will receive this parameter and returns the name or update a log file.
]]>