SQL触发器-它属于哪个表? [英] Sql Trigger - which table does it belong to?

查看:75
本文介绍了SQL触发器-它属于哪个表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Sql Server 2005触发器中是否有一种方法可以获取触发器在执行过程中附加到的表的名称和模式?

Is there a way within a Sql Server 2005 Trigger to get the name and schema of the table that the trigger is attached to during execution?

推荐答案

SELECT
    OBJECT_NAME(parent_id) AS [Table],
    OBJECT_NAME(object_id) AS TriggerName
FROM
    sys.triggers
WHERE
    object_id = @@PROCID

然后您也可以使用< a href = http://msdn.microsoft.com/zh-cn/library/ms176105.aspx rel = noreferrer>对象属性以获取更多信息,例如,在删除/插入/之后/之前更新,第一个/最后一个等

Then you can also use OBJECTPROPERTY to get extra info, such as after/before, delete/insert/update, first/last etc

这篇关于SQL触发器-它属于哪个表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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