How to list all triggers of all databases ?

  • I need know how to list all the triggers from all the databases hosted in my server. All the sp that i look run only over the current db. I use sql server 2000.

    Thanks in advance

  • Try making use of sp_msforeachdb undocumented stored procedure.

    Manu

  • Do you want to list their Names, or do want the listings (scripts) of all of the Triggers?

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • I need to list only the name of the triggers, the event of the trigger, and the table related with the trigger.

    thanks

  • I cannot test SQL 2000, but I believe that this should work:

    Declare @sql varchar(MAX)

    Set @sql = ''

    Select @sql = @sql + 'USE ' + name + '

    select '''+name+''' as DBName, p.name as [TableName], o.name, o.deltrig, o.instrig, o.updtrig

    from sysobjects o

    left outer join sysobjects p ON p.id = o.parent_obj

    where o.type=''TR''

    '

    from master..sysdatabases

    Where DBID > 4 --skip the system databases

    EXEC (@sql)

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • sp_msforeachdb 'use ? select db_name(), name from sysobjects where type = ''tr'''

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply