能否在触发器中得到当前这个触发器所在的表名(有些变态是不是?)

pabulum 2002-12-20 12:39:49
.
...全文
140 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2002-12-20
  • 打赏
  • 举报
回复
try


create table t (c1 int)
go

create trigger i_t on t for insert as
select object_name(parent_obj)
from sysobjects
where id = @@procid
go


愉快的登山者 2002-12-20
  • 打赏
  • 举报
回复
触发器是和表名绑在一起的,没有独立的触发器;所以表名可以在建立触发器时,直接赋值即可,为什么要找麻烦哪。
凋零的老树 2002-12-20
  • 打赏
  • 举报
回复
不能,触发器都是因为表存在而存在
pengdali 2002-12-20
  • 打赏
  • 举报
回复
哎呀!晚了!
pengdali 2002-12-20
  • 打赏
  • 举报
回复 1
select name from sysobjects where instrig=(select id from sysobjects where xtype='TR' and name='触发器名称')
happydreamer 2002-12-20
  • 打赏
  • 举报
回复
呵呵 saucer不愧是No.1 的专家啊
pabulum 2002-12-20
  • 打赏
  • 举报
回复
知道了,谢谢
saucer 2002-12-20
  • 打赏
  • 举报
回复
a field in sysobjects table

parent_obj int
Object identification number of parent object (for example, the table ID if a trigger or constraint)
pabulum 2002-12-20
  • 打赏
  • 举报
回复
parent_obj是什么?

34,873

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧