To view a table that has triggers in the database

Source: Internet
Author: User
This time in the project, in order to do the database synchronization, using the trigger mechanism, for the database to do the migration, we need to obtain the database of those tables using triggers, easy to make database installation package.

Idea:

The trigger is managed in MSSQL as an object, so we can get the query through the sysobjects table,
So we just wrote a trigger to get the SQL

SELECTobject_name(a.parent_obj) as [表],a.name as [触发器],(case when b.is_disabled=0 then ‘使用中’ else ‘停用’ end) as [触发器状态],b.create_date as [写入日期],b.modify_date as [最后修改日期],c.text as [触发器内容]FROM sysobjects aINNER JOIN sys.triggers bON b.object_id=a.idINNER JOIN syscomments cON c.id=a.idWHERE a.xtype=’tr’ ——tr代表类型 触发器ORDER BY [表]

To view a table that has triggers in the database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.