在SQL Server中找出调用存储过程 [英] Find out the calling stored procedure in SQL Server

查看:112
本文介绍了在SQL Server中找出调用存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有可能找出谁叫商店程序吗?

Is it possible to find out who called a store procedure?

例如,假设我在 proc3 中得到一个错误。从该proc中,我想知道是否由 proc1 proc2 调用。

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.

推荐答案

我将使用一个额外的输入参数来指定源代码,如果这对您的逻辑很重要。

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.

这篇关于在SQL Server中找出调用存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆