Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out the calling stored procedure in SQL Server

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.

like image 655
Craig Avatar asked Sep 29 '08 08:09

Craig


People also ask

How do you check where a stored procedure is called in SQL Server?

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.

Can view call stored 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.


1 Answers

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.

like image 68
GvS Avatar answered Oct 12 '22 02:10

GvS