mardi 30 juin 2015

MSSQL - How to know which SP called a function in real time

I need to know which procedure called, in real time, my function.

I need to store a log every time that my functions is called, and in that log I need to know the name of the SP that called it.

I found this:

select so.name 'Object Name', so2.name 'Dependent On', sd.*
from sys.sysdepends sd
join sys.objects so on so.object_id = sd.id
join sys.objects so2 on so2.object_id = sd.depid
where so2.name = 'FUNCTION_NAME'

But, this code returns the dependencies, I mean, all the SPs that were compiled calling the function BUT what I really need to know it the procedure that is actually, in that particular call, calling the function so I can store it in a Log Table.

Thanks!

Aucun commentaire:

Enregistrer un commentaire