如何列出(或导出)数据库中所有触发器的代码? [英] How do I list (or export) the code for all triggers in a database?
本文介绍了如何列出(或导出)数据库中所有触发器的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从数据库中的本地时间更改为UTC时间。
有很多触发器可以将信息复制到当前使用 GETDATE()的历史记录表中
。
I'm changing from local time to UTC-time in our database.
There are alot of triggers that copies information to history tables that currently uses GETDATE()
.
我想找到每个使用 GETDATE()
的触发器(而不是 GETUTCDATE()
),有什么方法可以自动执行此操作吗?
I would like to find every trigger that uses GETDATE()
(instead of GETUTCDATE()
) in the database, is there any way to do this automatic?
我已经列出了它们从sys.triggers中选择*
,但我还需要查看实际代码才能找到 GETDATE()$ c $的用法c>。
I've listed them by select * from sys.triggers
but I also need to see the actual code to be able to find the use of GETDATE()
.
推荐答案
您可以尝试以下操作:
SELECT o.[name],
c.[text]
FROM sys.objects AS o
INNER JOIN sys.syscomments AS c
ON o.object_id = c.id
WHERE o.[type] = 'TR'
这篇关于如何列出(或导出)数据库中所有触发器的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文