Is it possible to find out who called a store procedure?
For example, say I get an error in proc3
. From within that proc I want to know if it was called by proc1
or proc2
.
Using SQL Server Management Studio Expand Databases, expand the database in which the procedure belongs, and then expand Programmability. Expand Stored Procedures, right-click the procedure and then click View Dependencies. View the list of objects that depend on the procedure.
Answers. No, but most-likely you can convert your stored procedure to a table-valued function. Then you can call the table-valued function in a view.
I would use an extra input parameter, to specify the source, if this is important for your logic.
This will also make it easier to port your database to another platform, since you don't depend on some obscure platform dependent function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With